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”);
/* 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];
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.
/Users/username/Desktop/Test/build/Debug-iphoneos/Test.app: object file format invalid or unsuitableAfter 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
[myArray sortUsingSelector:@selector(caseInsensitiveCompare:)];
NSArray Class Reference -> sortedArrayUsingSelector
or:
[myArray sortUsingSelector:@selector(localizedCaseInsensitiveCompare:)];