218Obj-C, Shortcut: Boolean return value to String

Turning Boolean 1, 0 into a more descriptive description:

NSLog(@"data1 is equal to data2: %@", [data1 isEqualToData:data2] ? @"YES" : @"NO");

214NSMutableArray: setObject vs. setValue

Following situation Using TouchXML to parse XML data, works without problem on example XML files, but crahes on mine. Problem Empty values in my data set. (sometimes <place>somePlace</place>, sometimes <place></place>)

/* CXMLDocument setup & parsing omitted */
NSString *e = [[resultElement childAtIndex:counter] stringValue];
NSString *k = [[resultElement childAtIndex:counter] name];

[blogItem setObject:e forKey:k];
// crashes when e is empty. Displays a (null), is nil

Solution 1 Check for empty e, replace nil with empty string

// check if element is empty
if ( nil == e ) {   // ...or the less elegant (0 == [e length])
    e = @"";
}
[blogItem setObject:e forKey:k];

Solution 2 Use setValue instead of setObject, as setObject crashes and burns when it encounters nil, whereas setValue specifically deals only with strings and handles nil gracefully.

[blogItem setValue:e forKey:k];

212NSString and NSMutableString

Should have been clear, but was not:

NSString *s = @"aString";
s = @"anotherString";
NSLog(@"%@", s);
// anotherString

NSMutableString *m = @"aMutableString";
[m appendString:@"andAnAppendedString"];
NSLog(@"%@", m);
// aMutableStringandAnAppendedString

NString allows for the replacement of its whole content by simply assigning a new value.

With NSMutableString it is possible to add/delete/insert strings at arbitrary places in a string.

160@dynamic – Provide methods dynamically at runtime

"don't worry about it, a method is on the way."

http://theocacao.com/document.page/516

438VVOSC – Objective C OSC wrapper

source: http://github.com/mrRay/vvosc/tree/master docs: http://www.vidvox.net/rays_oddsnends/vvosc_doc/

after following the instructions in the docs, i get the following error (iPod Touch 2nd, OS3.0 beta 5)

/Users/username/Desktop/Test/build/Debug-iphoneos/Test.app: object file format invalid or unsuitable

After some googling, I came across this, and it seems to do the trick.

add:

$(SDKROOT)/ResourceRules.plist

to the Code Signing Resource Path. Why exactly it's working is anybody's guess.

~

This might also be worth a look: liblo: Lightweight OSC implementation

112(NSError **)error

What is this ** doing again?

Oh yeah, thisand that.

13Syntax error at ‘OTHER’ token

Error message, can not compile due to Unicode characters in Source code. Watch out for Kanji spaces. Line height seems to be a bit off, if Kanji is mixed it.

11UITableViewController…

  • simple subclass of UITableController
  • for Fullscreen tables only
  • create UITableView with loadView
  • set delegate & dataSource to itself

9Obj-C: Sorting Array

[myArray sortUsingSelector:@selector(caseInsensitiveCompare:)];

NSArray Class Reference -> sortedArrayUsingSelector

or:

[myArray sortUsingSelector:@selector(localizedCaseInsensitiveCompare:)];