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");
Turning Boolean 1, 0 into a more descriptive description:
NSLog(@"data1 is equal to data2: %@", [data1 isEqualToData:data2] ? @"YES" : @"NO");
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];
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.
"don't worry about it, a method is on the way."
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
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.
[myArray sortUsingSelector:@selector(caseInsensitiveCompare:)];
NSArray Class Reference -> sortedArrayUsingSelector
or:
[myArray sortUsingSelector:@selector(localizedCaseInsensitiveCompare:)];