Tuesday, December 14, 2010

google latitude in app store

Even this blogs main purpose is to write about development here and there ill post apps,technologies and tools i find especially usefull or cool....

Google latitude hit the app store this week and I must say its great. It took some time to come over from Android but it finally made it. I already felt in love with it on my old HTC Magic and am really happy about the look and feel on iOS.

Hope to see many more Google Apps on iOS Devices (even though they have there own OS) in the future...

JSON in iPhone/iPad App

For you out there searching for a good JSON library for your iOS project this is the one Im using:


https://github.com/stig/json-framework/downloads

Howto use:

  1. Add folder to your project
  2. Import the header file (#import "JSON.h")
  3. When you have a NSString containing JSON data simply use: [strSomeString JSONValue]; and you get an NSDictionary/NSArray

Very simple :-)


Cheers,

JayEs

Monday, December 13, 2010

For/Foreach -> php vs objective-c

Lets start with a short Post about for/foreach PHP vs Objective-C
 To loop through an array in php is very simple:

foreach($arrData as $key => $value){
    //do something...
}

or

for($i = 0; $i < count($arrData); $i++){
    //do somethin... 
}

In Objective-C you have similar possibilities but you have to be sure what kind of object you are dealing with e.g. NSDictionary* or NSArray*

To get an Element of these two types you do as follows:

NSDictionary

NSDictionary* arrData = ...;
 [arrData objectForKey:@"id"];

Loop

for (NSString* key in arrData) {
        id value = [arrData objectForKey:key];
}

NSArray


NSArray* arrData = ...;
 [arrData objectAtIndex:1];

Loop

for (int i = 0; i < [arrData count]; i++) {
     [arrData objectAtIndex:i];
}

Besides these options you can also use enumerateKeysAndObjectsWithOptions. But I personaly dislike it cause it "feels" bad.

If you have an array of similar objects and you want all of them to perform the same selector you can also do this:

[[self.view subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];

This will save you some lines of code and is very "readable".

Cheers

JayEs

Sunday, December 12, 2010

First Post

This is going to be a blog about dev and tech related topics.
The main topics regarding development will be:
  • Objective-C / Cocoa
  • PHP
  • Java / Android
 Like many developers when faceing a specific problem I often start googling for it to see how other people solved it. This Blog shall show code blogs I found usefull or highlight specific topics the community asks for. To help others out there trying to solve a task...