Merging NSArrays in Objective-C
Just use [newArray addObjectsFromArray:anArray];
Just use [newArray addObjectsFromArray:anArray];
Here’s what you’d want: Class theClass = NSClassFromString(classNameStr); id myObject = [[theClass alloc] init]; Note that you can’t use theClass as a type name (i.e. theClass *myObject). You’ll have to use id for that.
Looks like you didn’t install CocoaPods. To do that you install it through ruby gems, like this: sudo gem install cocoapods If you don’t have admin privileges, try: gem install cocoapods –user-install
Try to make your own NSNumberFormatter subclass and check the input value in -isPartialStringValid:newEditingString:errorDescription: method. @interface OnlyIntegerValueFormatter : NSNumberFormatter @end @implementation OnlyIntegerValueFormatter – (BOOL)isPartialStringValid:(NSString*)partialString newEditingString:(NSString**)newString errorDescription:(NSString**)error { if([partialString length] == 0) { return YES; } NSScanner* scanner = [NSScanner scannerWithString:partialString]; if(!([scanner scanInt:0] && [scanner isAtEnd])) { NSBeep(); return NO; } return YES; } @end And … Read more
Since in practice the NSText* returned by -currentEditor for an NSTextField is always an NSTextView*, I added the following code to my custom NSTextField subclass: -(BOOL) becomeFirstResponder { BOOL success = [super becomeFirstResponder]; if( success ) { // Strictly spoken, NSText (which currentEditor returns) doesn’t // implement setInsertionPointColor:, but it’s an NSTextView in practice. // … Read more
The sender should be the control which initiated the action. However, you should not assume its type and should instead leave it defined as an id. Instead, check for the object’s class in the actual method as follows: – (IBAction)onClick1:(id)sender { // Make sure it’s a UIButton if (![sender isKindOfClass:[UIButton class]]) return; NSString *title = … Read more
For 10.6 this works: NSNumberFormatter* numberFormatter = [[NSNumberFormatter alloc] init]; [numberFormatter setFormatterBehavior: NSNumberFormatterBehavior10_4]; [numberFormatter setNumberStyle: NSNumberFormatterDecimalStyle]; NSString *numberString = [numberFormatter stringFromNumber: [NSNumber numberWithInteger: i]]; And it properly handles localization.
If you’re using a transparent sheet, you don’t know in advance what the pixels below it will be. They may change. Remember that you have a single alpha channel for all three colors: if you make it transparent, you won’t see any subpixel effect, but if you make it opaque, all three subelements are going … Read more
After a lot of disappointing testing I’ve come to the following conclusions. Though logical, they’re disappointing since the resulting experience for users is far from ideal and a significant pain for developers depending on how far they’re willing to go to help users re-establish references to bookmarked resources. When I say “renew” below, I mean … Read more