iOS 7 bug or my bug in UIAlertView
Stupid me, I just have to set the alert view’s delegate to nil
Stupid me, I just have to set the alert view’s delegate to nil
self.object = nil calls your setter, which will release the old value, set the member to nil, and possibly do other things (it’s a method, so it could do anything). The “anything” part of that is potentially dangerous; see this question, for example. [object release] releases the old value, but leaves the member as a … Read more
One way is to use AssetsLibrary and use n – 1 as the index for enumeration. ALAssetsLibrary *assetsLibrary = [[ALAssetsLibrary alloc] init]; [assetsLibrary enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop) { if (nil != group) { // be sure to filter the group so you only get photos [group setAssetsFilter:[ALAssetsFilter allPhotos]]; if (group.numberOfAssets > 0) { [group … Read more
The short answer is that you’re using UINavigationController, and that won’t work like you want it to. From Apple’s docs: Why won’t my UIViewController rotate with the device? All child view controllers in your UITabBarController or UINavigationController do not agree on a common orientation set. To make sure that all your child view controllers rotate … Read more
Here’s a relatively simple approach. Just create an NSAttributedString with the appropriate font and ask for its size: – (CGFloat)widthOfString:(NSString *)string withFont:(NSFont *)font { NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:font, NSFontAttributeName, nil]; return [[[NSAttributedString alloc] initWithString:string attributes:attributes] size].width; }
Recent versions of llvm have added an attribute that indicates that subclasses must call super: @interface Barn:NSObject – (void)openDoor NS_REQUIRES_SUPER; @end @implementation Barn – (void) openDoor { ; } @end @interface HorseBarn:Barn @end @implementation HorseBarn – (void) openDoor { ; } @end Compiling the above produces the warning: Method possibly missing a [super openDoor] call
Menu mouse tracking is done in a special run loop mode (NSEventTrackingRunLoopMode). In order to modify the menu, you need to dispatch a message so that it will be processed in the event tracking mode. The easiest way to do this is to use this method of NSRunLoop: [[NSRunLoop currentRunLoop] performSelector:@selector(updateTheMenu:) target:self argument:yourMenu order:0 modes:[NSArray … Read more
I figured it out within minutes of posting my comment. Adding my finding as an answer because it is an example which is missing in the docs. The below code will give you the viewDidLoad method that you want. Its so easy in a way that i wonder why Apple has not implemented it yet … Read more
Yes. Use the MFMailComposeViewController. // From within your active view controller if([MFMailComposeViewController canSendMail]) { MFMailComposeViewController *mailCont = [[MFMailComposeViewController alloc] init]; mailCont.mailComposeDelegate = self; [mailCont setSubject:@”yo!”]; [mailCont setToRecipients:[NSArray arrayWithObject:@”[email protected]”]]; [mailCont setMessageBody:@”Don’t ever want to give you up” isHTML:NO]; [self presentViewController:mailCont animated:YES completion:nil]; } // Then implement the delegate method – (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error { [self dismissViewControllerAnimated:YES … Read more
With a variable typed id, you can send it any known message and the compiler will not complain. With a variable typed NSObject *, you can only send it messages declared by NSObject (not methods of any subclass) or else it will generate a warning. In general, id is what you want. Further explanation: All … Read more