iphone Programming Glossary: first
How to check for an active Internet Connection on iPhone SDK? http://stackoverflow.com/questions/1083701/how-to-check-for-an-active-internet-connection-on-iphone-sdk check 7 In the .m file of where you are implementing the check you can place this in one of the first methods called init or viewWillAppear or viewDidLoad etc void viewWillAppear BOOL animated check for..
How to add a breakpoint to objc_exception_throw? http://stackoverflow.com/questions/1163981/how-to-add-a-breakpoint-to-objc-exception-throw two global breakpoints I do them globally because they are so useful in all my applications . The first should be named objc_exception_throw and its location should be libobjc.A.dylib . The second should..
Reading ePub format http://stackoverflow.com/questions/1388467/reading-epub-format if this file doesn't exist the EPUB is invalid using TBXML linked above 5 In this XML find the first rootfile with media type application oebps package xml . This is the OPF file for the book. 6 parse.. . This is the OPF file for the book. 6 parse the OPF file also XML 7 now you need to know what the first chapter of the book is. a each item in the manifest element has an id and an href. Store these in an.. Store these in an NSDictionary where the key is the id and the object is the href. b Look at the first itemref in the spine . It has an idref attribute which corresponds to one of the ids in a . Look up..
AES Encryption for an NSString on the iPhone http://stackoverflow.com/questions/1400246/aes-encryption-for-an-nsstring-on-the-iphone then return an NSString created from the encrypted data. I've tried the technique detailed in the first comment on this post but I've had no luck so far. Apple's CryptoExercise certainly has something but..
How do I detect when someone shakes an iPhone? http://stackoverflow.com/questions/150446/how-do-i-detect-when-someone-shakes-an-iphone events. The main trick is that you need to have some UIView not UIViewController that you want as firstResponder to receive the shake event messages. Here's the code that you can use in any UIView to get.. IB or using it when allocating a view . In the view controller you want to set this view to become first responder void viewWillAppear BOOL animated shakeView becomeFirstResponder super viewWillAppear animated.. super viewWillDisappear animated Don't forget that if you have other views that become first responder from user actions like a search bar or text entry field you'll also need to restore the shaking..
How to force NSLocalizedString to use a specific language http://stackoverflow.com/questions/1669645/how-to-force-nslocalizedstring-to-use-a-specific-language the user's settings for preferred languages are. This returns an array of language codes with the first one being the one set by the user for their phone and the subsequent ones used as fallbacks if a resource..
Programmatically get own phone number in iOS http://stackoverflow.com/questions/193182/programmatically-get-own-phone-number-in-ios risk of getting negative marks I want to suggest that the highest ranking solution currently the first response violates the latest SDK Agreement as of Nov 5 2009. Our application was just rejected for using..
How to take a screenshot programmatically http://stackoverflow.com/questions/2200736/how-to-take-a-screenshot-programmatically image data writeToFile @ foo.png atomically YES UPDATE April 2011 for retina display change the first line into this if UIScreen mainScreen respondsToSelector @selector scale UIGraphicsBeginImageContextWithOptions..
Can I embed a custom font in an iPhone application? http://stackoverflow.com/questions/360751/can-i-embed-a-custom-font-in-an-iphone-application on iPhone. Consequently I am setting a bounty for this question and I will award the bounty to the first person who provides an answer using only documented APIs who responds with sufficient information to..
parsing HTML on the iPhone [closed] http://stackoverflow.com/questions/405749/parsing-html-on-the-iphone of the 3rd table NSArray elements xpathParser searchWithXPathQuery @ table 3 tr 2 td Access the first cell TFHppleElement element elements objectAtIndex 0 Get the text within the cell tag NSString content..
How to link to apps on the app store http://stackoverflow.com/questions/433907/how-to-link-to-apps-on-the-app-store itunes.apple.com WebObjects MZStore.woa wa viewSoftware id 300136119 mt 8 the iphone opens safari first and then the app store. I have used other apps that open the app store directly so I know it is possible...
iPhone/iOS JSON parsing tutorial [closed] http://stackoverflow.com/questions/5813077/iphone-ios-json-parsing-tutorial that response to populate the rows of a UITableView assuming it converts the JSON into an NSArray first . Anyone know of anything that might be useful iphone objective c ios json uitableview share improve..
What is the best way to deal with the NSDateFormatter locale “feature”? http://stackoverflow.com/questions/6613110/what-is-the-best-way-to-deal-with-the-nsdateformatter-locale-feature loc release Not too bad in onsies twosies but I'm dealing with about ten different apps and the first one I look at has 43 instances of this scenario. So any clever ideas for a macro overridden class whatever.. class whatever to minimize the effort to change everything without making the code to obscure My first instinct is to override NSDateFormatter with a version that would set the locale in the init method...
UIDevice uniqueIdentifier Deprecated - What To Do Now? http://stackoverflow.com/questions/6993325/uidevice-uniqueidentifier-deprecated-what-to-do-now to the old UIDevice uniqueIdentifier but a UUID that is created when the app starts for the first time is what Apple seems to want you to use . Edit 3 So this major point doesn't get lost in the comment..
HTML character decoding in Objective-C / Cocoa Touch http://stackoverflow.com/questions/1105169/html-character-decoding-in-objective-c-cocoa-touch character decoding in Objective C Cocoa Touch First of all I found this Objective C HTML escape unescape but it doesn't work for me. My encoded characters..
How would I tint an image programatically on the iPhone? http://stackoverflow.com/questions/1117211/how-would-i-tint-an-image-programatically-on-the-iphone alpha 1.0 draw image iphone cocoa touch image processing share improve this question First you'll want to subclass UIImageView and override the drawRect method. Your class needs a UIColor property..
How can I animate the movement of a view or image along a curved path? http://stackoverflow.com/questions/1142727/how-can-i-animate-the-movement-of-a-view-or-image-along-a-curved-path image of a view into an icon to indicate saving as can be seen in the video for this application First of all import QuartzCore header file #import QuartzCore QuartzCore.h UIImageView imageViewForAnimation..
MKMapView Zoom and Region http://stackoverflow.com/questions/1166444/mkmapview-zoom-and-region zoom level on a MKMapView Thanks iphone cocoa touch mapkit zoom share improve this question First of all MKMapView does not use have a predefined set of zoom levels like Google Maps does. Instead the..
How to detect iPhone 5 (widescreen devices)? http://stackoverflow.com/questions/12446990/how-to-detect-iphone-5-widescreen-devices view. How should I do that iphone ios objective c screen device share improve this question First of all you shouldn't rebuild all your views to fit a new screen nor use different views for different..
Programmatically Request Access to Contacts http://stackoverflow.com/questions/12648244/programmatically-request-access-to-contacts addressBookRef ^ bool granted CFErrorRef error if granted First time access has been granted add the contact self _addContactToAddressBook else User denied access..
Assertion failure in dequeueReusableCellWithIdentifier:forIndexPath: http://stackoverflow.com/questions/12737860/assertion-failure-in-dequeuereusablecellwithidentifierforindexpath must register a nib or a class for the identifier or connect a prototype cell in a storyboard' First throw call stack 0x1c91012 0x10cee7e 0x1c90e78 0xb64f35 0xc7d14 0x39ff 0xd0f4b 0xd101f 0xb980b 0xca19b..
NSURLConnection and Basic HTTP Authentication http://stackoverflow.com/questions/1973325/nsurlconnection-and-basic-http-authentication have the username password so there's no need for a challenge from the server for authorization. First question 1 Does NSURLConnection have to be set as synchronous to do Basic Auth According to the answer..
How to store custom objects in NSUserDefaults http://stackoverflow.com/questions/2315948/how-to-store-custom-objects-in-nsuserdefaults UIApplication application NSUserDefaults prefs NSUserDefaults standardUserDefaults First check to see if some things exist int startup prefs integerForKey @ appHasLaunched if startup nil Make..
JSON and Core Data on the iPhone http://stackoverflow.com/questions/2362323/json-and-core-data-on-the-iphone would be gratefully received. iphone objective c json core data share improve this question First pick a JSON library to use I personally like TouchJSON but several others out there are quite nice as..
How can I send mail from an iPhone application http://stackoverflow.com/questions/310946/how-can-i-send-mail-from-an-iphone-application the MFMailComposeViewControllerDelegate protocol that is tucked away in the MessageUI framework. First add the framework and import #import MessageUI MFMailComposeViewController.h Then to send a message..
Build fat static library (device + simulator) using Xcode and SDK 4+ http://stackoverflow.com/questions/3520977/build-fat-static-library-device-simulator-using-xcode-and-sdk-4 echo TARGET_BUILD_DIR TARGET_BUILD_DIR fi ##################### part 1 ################## # First work out the BASESDK version number NB Apple ought to report this but they hide it # incidental searching..
iPhone App Minus App Store? http://stackoverflow.com/questions/37464/iphone-app-minus-app-store tested using the AccelerometerGraph sample app on iPhone OS 3.0. Create Self Signed Certificate First you'll need to create a self signed certificate and patch your iPhone SDK to allow the use of this certificate..
iOS SDK - Programmatically generate a PDF file http://stackoverflow.com/questions/4362734/ios-sdk-programmatically-generate-a-pdf-file iphone objective c ipad ios pdf generation share improve this question A couple things... First there is a bug with CoreGraphics PDF generation in iOS that results in corrupted PDFs. I know this issue..
Round two corners in UIView http://stackoverflow.com/questions/4847163/round-two-corners-in-uiview methods in a couple of projects last year then I hope you can find something useful. Solution 1 First of all I created this function to generate an image mask on the fly UIImage with the rounded corner..
What's the best way to communicate between view controllers? http://stackoverflow.com/questions/569940/whats-the-best-way-to-communicate-between-view-controllers research and seem concerned with learning how to do it right instead of just hacking it together. First I agree with the previous answers which focus on the importance of putting data in model objects when..
Make movie file with picture Array and song file, using AVAsset http://stackoverflow.com/questions/6061092/make-movie-file-with-picture-array-and-song-file-using-avasset array and an audio file. So if you want do the same thing I put my code here be careful to memory First make a movie file with your picture array use zoul's post here void writeImagesToMovieAtPath NSString..
Custom colors in UITabBar http://stackoverflow.com/questions/675433/custom-colors-in-uitabbar improve this question I found an answer to this at Silent Mac Design . I implemented this way First make a subclass of UITabBarContoller CustomUITabBarController.h #import UIKit UIKit.h @interface CustomUITabBarController..
iCloud basics and code sample [closed] http://stackoverflow.com/questions/7795629/icloud-basics-and-code-sample to work. When I create a new instance of an UIDocument I'll have to overwrite two methods. First BOOL loadFromContents id contents ofType NSString typeName error NSError outError to get files from.. _textView @synthesize document _document IBAction dismissKeyboard id sender _textView resignFirstResponder void noteDocumentContentsUpdated MyTextDocument noteDocument NSLog @ VC noteDocumentsUpdated..
To ARC or not to ARC? What are the pros and cons? http://stackoverflow.com/questions/8760431/to-arc-or-not-to-arc-what-are-the-pros-and-cons memory management rules. This is mostly true but it's important to understand why and why not. First if all of your code uses ARC and you violate the Three Magic Words all over the place you'll still have..
How to check for an active Internet Connection on iPhone SDK? http://stackoverflow.com/questions/1083701/how-to-check-for-an-active-internet-connection-on-iphone-sdk Reachability.h to the .m file where you are implementing the check 7 In the .m file of where you are implementing the check you can place this in one of the first methods called init or viewWillAppear or viewDidLoad etc void viewWillAppear BOOL animated check for internet connection NSNotificationCenter defaultCenter addObserver..
How to add a breakpoint to objc_exception_throw? http://stackoverflow.com/questions/1163981/how-to-add-a-breakpoint-to-objc-exception-throw exceptions. To do this go to Run Show Breakpoints and create two global breakpoints I do them globally because they are so useful in all my applications . The first should be named objc_exception_throw and its location should be libobjc.A.dylib . The second should be NSException raise and its location should be CoreFoundation..
Reading ePub format http://stackoverflow.com/questions/1388467/reading-epub-format linked above 4 parse the XML file at META INF container.xml if this file doesn't exist the EPUB is invalid using TBXML linked above 5 In this XML find the first rootfile with media type application oebps package xml . This is the OPF file for the book. 6 parse the OPF file also XML 7 now you need to know what the first.. rootfile with media type application oebps package xml . This is the OPF file for the book. 6 parse the OPF file also XML 7 now you need to know what the first chapter of the book is. a each item in the manifest element has an id and an href. Store these in an NSDictionary where the key is the id and the object is the.. a each item in the manifest element has an id and an href. Store these in an NSDictionary where the key is the id and the object is the href. b Look at the first itemref in the spine . It has an idref attribute which corresponds to one of the ids in a . Look up that id in the NSDictionary and you'll get an href. c this is..
AES Encryption for an NSString on the iPhone http://stackoverflow.com/questions/1400246/aes-encryption-for-an-nsstring-on-the-iphone is supplied with the encrypted data. The method should then return an NSString created from the encrypted data. I've tried the technique detailed in the first comment on this post but I've had no luck so far. Apple's CryptoExercise certainly has something but I can't make sense of it... I've seen lots of references to..
How do I detect when someone shakes an iPhone? http://stackoverflow.com/questions/150446/how-do-i-detect-when-someone-shakes-an-iphone In 3.0 there's now an easier way hook into the new motion events. The main trick is that you need to have some UIView not UIViewController that you want as firstResponder to receive the shake event messages. Here's the code that you can use in any UIView to get shake events @implementation ShakingView void motionEnded UIEventSubtype.. then selecting this new type instead of the base type in IB or using it when allocating a view . In the view controller you want to set this view to become first responder void viewWillAppear BOOL animated shakeView becomeFirstResponder super viewWillAppear animated void viewWillDisappear BOOL animated shakeView resignFirstResponder.. void viewWillDisappear BOOL animated shakeView resignFirstResponder super viewWillDisappear animated Don't forget that if you have other views that become first responder from user actions like a search bar or text entry field you'll also need to restore the shaking view first responder status when the other view resigns..
How to force NSLocalizedString to use a specific language http://stackoverflow.com/questions/1669645/how-to-force-nslocalizedstring-to-use-a-specific-language the AppleLanguages key in NSUserDefaults to determine what the user's settings for preferred languages are. This returns an array of language codes with the first one being the one set by the user for their phone and the subsequent ones used as fallbacks if a resource is not available in the preferred language. on the desktop..
Programmatically get own phone number in iOS http://stackoverflow.com/questions/193182/programmatically-get-own-phone-number-in-ios phones phone number share improve this question At the risk of getting negative marks I want to suggest that the highest ranking solution currently the first response violates the latest SDK Agreement as of Nov 5 2009. Our application was just rejected for using it. Here's the response from Apple For security reasons..
How to take a screenshot programmatically http://stackoverflow.com/questions/2200736/how-to-take-a-screenshot-programmatically UIGraphicsEndImageContext NSData data UIImagePNGRepresentation image data writeToFile @ foo.png atomically YES UPDATE April 2011 for retina display change the first line into this if UIScreen mainScreen respondsToSelector @selector scale UIGraphicsBeginImageContextWithOptions self.window.bounds.size NO UIScreen mainScreen .scale..
Can I embed a custom font in an iPhone application? http://stackoverflow.com/questions/360751/can-i-embed-a-custom-font-in-an-iphone-application In one case X turned out to be relevant only on OS X not on iPhone. Consequently I am setting a bounty for this question and I will award the bounty to the first person who provides an answer using only documented APIs who responds with sufficient information to get this working on the device. Working on the simulator too..
parsing HTML on the iPhone [closed] http://stackoverflow.com/questions/405749/parsing-html-on-the-iphone alloc initWithHTMLData data Get all the cells of the 2nd row of the 3rd table NSArray elements xpathParser searchWithXPathQuery @ table 3 tr 2 td Access the first cell TFHppleElement element elements objectAtIndex 0 Get the text within the cell tag NSString content element content xpathParser release data release Known issues..
How to link to apps on the app store http://stackoverflow.com/questions/433907/how-to-link-to-apps-on-the-app-store paid version in the app store. If I use a standard link http itunes.apple.com WebObjects MZStore.woa wa viewSoftware id 300136119 mt 8 the iphone opens safari first and then the app store. I have used other apps that open the app store directly so I know it is possible. Any ideas What is the URL Scheme for the app store iphone..
iPhone/iOS JSON parsing tutorial [closed] http://stackoverflow.com/questions/5813077/iphone-ios-json-parsing-tutorial a webserver webservice retrieves a JSON response and uses that response to populate the rows of a UITableView assuming it converts the JSON into an NSArray first . Anyone know of anything that might be useful iphone objective c ios json uitableview share improve this question You will love this framework . And you will..
What is the best way to deal with the NSDateFormatter locale “feature”? http://stackoverflow.com/questions/6613110/what-is-the-best-way-to-deal-with-the-nsdateformatter-locale-feature alloc initWithLocaleIdentifier @ en_US df setLocale loc loc release Not too bad in onsies twosies but I'm dealing with about ten different apps and the first one I look at has 43 instances of this scenario. So any clever ideas for a macro overridden class whatever to minimize the effort to change everything without making.. of this scenario. So any clever ideas for a macro overridden class whatever to minimize the effort to change everything without making the code to obscure My first instinct is to override NSDateFormatter with a version that would set the locale in the init method. Requires changing two lines the alloc init line and the added..
UIDevice uniqueIdentifier Deprecated - What To Do Now? http://stackoverflow.com/questions/6993325/uidevice-uniqueidentifier-deprecated-what-to-do-now . In most cases you should be able use it as a drop in replacement to the old UIDevice uniqueIdentifier but a UUID that is created when the app starts for the first time is what Apple seems to want you to use . Edit 3 So this major point doesn't get lost in the comment noise do not use the MAC as UUID create a hash using the..
HTML character decoding in Objective-C / Cocoa Touch http://stackoverflow.com/questions/1105169/html-character-decoding-in-objective-c-cocoa-touch character decoding in Objective C Cocoa Touch First of all I found this Objective C HTML escape unescape but it doesn't work for me. My encoded characters come from a RSS feed btw look like this #038 I searched all..
How would I tint an image programatically on the iPhone? http://stackoverflow.com/questions/1117211/how-would-i-tint-an-image-programatically-on-the-iphone @ someImage.png drawInRect rect blendMode kCGBlendModeOverlay alpha 1.0 draw image iphone cocoa touch image processing share improve this question First you'll want to subclass UIImageView and override the drawRect method. Your class needs a UIColor property let's call it overlayColor to hold the blend color and..
How can I animate the movement of a view or image along a curved path? http://stackoverflow.com/questions/1142727/how-can-i-animate-the-movement-of-a-view-or-image-along-a-curved-path For example I've used the following code to animate an image of a view into an icon to indicate saving as can be seen in the video for this application First of all import QuartzCore header file #import QuartzCore QuartzCore.h UIImageView imageViewForAnimation UIImageView alloc initWithImage imageToAnimate imageViewForAnimation.alpha..
MKMapView Zoom and Region http://stackoverflow.com/questions/1166444/mkmapview-zoom-and-region bonus question is there any way to specify a minimum maximum zoom level on a MKMapView Thanks iphone cocoa touch mapkit zoom share improve this question First of all MKMapView does not use have a predefined set of zoom levels like Google Maps does. Instead the visible area of a MKMapView is described using MKCoordinateRegion..
How to detect iPhone 5 (widescreen devices)? http://stackoverflow.com/questions/12446990/how-to-detect-iphone-5-widescreen-devices user has an iPhone with 3.5 or 4 screen and then apply the view. How should I do that iphone ios objective c screen device share improve this question First of all you shouldn't rebuild all your views to fit a new screen nor use different views for different screen sizes. Use the auto resizing capabilities of iOS so..
Programmatically Request Access to Contacts http://stackoverflow.com/questions/12648244/programmatically-request-access-to-contacts kABAuthorizationStatusNotDetermined ABAddressBookRequestAccessWithCompletion addressBookRef ^ bool granted CFErrorRef error if granted First time access has been granted add the contact self _addContactToAddressBook else User denied access Display an alert telling user the contact could not be added..
Assertion failure in dequeueReusableCellWithIdentifier:forIndexPath: http://stackoverflow.com/questions/12737860/assertion-failure-in-dequeuereusablecellwithidentifierforindexpath reason 'unable to dequeue a cell with identifier Cell must register a nib or a class for the identifier or connect a prototype cell in a storyboard' First throw call stack 0x1c91012 0x10cee7e 0x1c90e78 0xb64f35 0xc7d14 0x39ff 0xd0f4b 0xd101f 0xb980b 0xca19b 0x6692d 0x10e26b0 0x228dfc0 0x228233c 0x228deaf 0x1058cd..
NSURLConnection and Basic HTTP Authentication http://stackoverflow.com/questions/1973325/nsurlconnection-and-basic-http-authentication first time the request is sent to the server and I already have the username password so there's no need for a challenge from the server for authorization. First question 1 Does NSURLConnection have to be set as synchronous to do Basic Auth According to the answer on this post it seems that you can't do Basic Auth if you..
How to store custom objects in NSUserDefaults http://stackoverflow.com/questions/2315948/how-to-store-custom-objects-in-nsuserdefaults window @synthesize mainViewController void applicationDidFinishLaunching UIApplication application NSUserDefaults prefs NSUserDefaults standardUserDefaults First check to see if some things exist int startup prefs integerForKey @ appHasLaunched if startup nil Make the single player Player singlePlayer Player alloc init NSLog..
JSON and Core Data on the iPhone http://stackoverflow.com/questions/2362323/json-and-core-data-on-the-iphone for a tutorial code sample on this point so any assistance would be gratefully received. iphone objective c json core data share improve this question First pick a JSON library to use I personally like TouchJSON but several others out there are quite nice as well. The complicated part although not very hard is to convert..
How can I send mail from an iPhone application http://stackoverflow.com/questions/310946/how-can-i-send-mail-from-an-iphone-application you should use the MFMailComposeViewController class and the MFMailComposeViewControllerDelegate protocol that is tucked away in the MessageUI framework. First add the framework and import #import MessageUI MFMailComposeViewController.h Then to send a message MFMailComposeViewController controller MFMailComposeViewController..
Build fat static library (device + simulator) using Xcode and SDK 4+ http://stackoverflow.com/questions/3520977/build-fat-static-library-device-simulator-using-xcode-and-sdk-4 echo CONFIGURATION_TEMP_DIR CONFIGURATION_TEMP_DIR echo TARGET_BUILD_DIR TARGET_BUILD_DIR fi ##################### part 1 ################## # First work out the BASESDK version number NB Apple ought to report this but they hide it # incidental searching for substrings in sh is a nightmare Sob SDK_VERSION echo..
iPhone App Minus App Store? http://stackoverflow.com/questions/37464/iphone-app-minus-app-store you can use the following method which I have personally tested using the AccelerometerGraph sample app on iPhone OS 3.0. Create Self Signed Certificate First you'll need to create a self signed certificate and patch your iPhone SDK to allow the use of this certificate Launch Keychain Access.app. With no items selected..
iOS SDK - Programmatically generate a PDF file http://stackoverflow.com/questions/4362734/ios-sdk-programmatically-generate-a-pdf-file Here's an example on GitHub using libHaru in an iPhone project. iphone objective c ipad ios pdf generation share improve this question A couple things... First there is a bug with CoreGraphics PDF generation in iOS that results in corrupted PDFs. I know this issue exists up to and including iOS 4.1 I haven't tested iOS..
Round two corners in UIView http://stackoverflow.com/questions/4847163/round-two-corners-in-uiview also fast. Both are based on CALayer masking. I've used both methods in a couple of projects last year then I hope you can find something useful. Solution 1 First of all I created this function to generate an image mask on the fly UIImage with the rounded corner I need. This function essentially needs 5 parameters the bounds..
What's the best way to communicate between view controllers? http://stackoverflow.com/questions/569940/whats-the-best-way-to-communicate-between-view-controllers good questions and its great to see that you're doing this research and seem concerned with learning how to do it right instead of just hacking it together. First I agree with the previous answers which focus on the importance of putting data in model objects when appropriate per the MVC design pattern . Usually you want..
Make movie file with picture Array and song file, using AVAsset http://stackoverflow.com/questions/6061092/make-movie-file-with-picture-array-and-song-file-using-avasset question I finally found how make movie with a picture array and an audio file. So if you want do the same thing I put my code here be careful to memory First make a movie file with your picture array use zoul's post here void writeImagesToMovieAtPath NSString path withSize CGSize size NSString documentsDirectoryPath..
Custom colors in UITabBar http://stackoverflow.com/questions/675433/custom-colors-in-uitabbar Apple's Human Interface Guidelines iphone objective c share improve this question I found an answer to this at Silent Mac Design . I implemented this way First make a subclass of UITabBarContoller CustomUITabBarController.h #import UIKit UIKit.h @interface CustomUITabBarController UITabBarController IBOutlet UITabBar tabBar1..
iCloud basics and code sample [closed] http://stackoverflow.com/questions/7795629/icloud-basics-and-code-sample problem is a fundamental misunderstanding of how iCloud is supposed to work. When I create a new instance of an UIDocument I'll have to overwrite two methods. First BOOL loadFromContents id contents ofType NSString typeName error NSError outError to get files from the cloud and then id contentsForType NSString typeName error.. @implementation ViewController @synthesize textView _textView @synthesize document _document IBAction dismissKeyboard id sender _textView resignFirstResponder void noteDocumentContentsUpdated MyTextDocument noteDocument NSLog @ VC noteDocumentsUpdated _textView.text noteDocument.documentText void textViewDidChange..
To ARC or not to ARC? What are the pros and cons? http://stackoverflow.com/questions/8760431/to-arc-or-not-to-arc-what-are-the-pros-and-cons the lines of using ARC is no substitute for knowing the Cocoa memory management rules. This is mostly true but it's important to understand why and why not. First if all of your code uses ARC and you violate the Three Magic Words all over the place you'll still have no problems. Shocking to say but there you go. ARC might..
How to check for an active Internet Connection on iPhone SDK? http://stackoverflow.com/questions/1083701/how-to-check-for-an-active-internet-connection-on-iphone-sdk are implementing the check 7 In the .m file of where you are implementing the check you can place this in one of the first methods called init or viewWillAppear or viewDidLoad etc void viewWillAppear BOOL animated check for internet connection..
How to add a breakpoint to objc_exception_throw? http://stackoverflow.com/questions/1163981/how-to-add-a-breakpoint-to-objc-exception-throw and create two global breakpoints I do them globally because they are so useful in all my applications . The first should be named objc_exception_throw and its location should be libobjc.A.dylib . The second should be NSException raise..
Reading ePub format http://stackoverflow.com/questions/1388467/reading-epub-format META INF container.xml if this file doesn't exist the EPUB is invalid using TBXML linked above 5 In this XML find the first rootfile with media type application oebps package xml . This is the OPF file for the book. 6 parse the OPF file also XML.. oebps package xml . This is the OPF file for the book. 6 parse the OPF file also XML 7 now you need to know what the first chapter of the book is. a each item in the manifest element has an id and an href. Store these in an NSDictionary where.. an id and an href. Store these in an NSDictionary where the key is the id and the object is the href. b Look at the first itemref in the spine . It has an idref attribute which corresponds to one of the ids in a . Look up that id in the NSDictionary..
AES Encryption for an NSString on the iPhone http://stackoverflow.com/questions/1400246/aes-encryption-for-an-nsstring-on-the-iphone The method should then return an NSString created from the encrypted data. I've tried the technique detailed in the first comment on this post but I've had no luck so far. Apple's CryptoExercise certainly has something but I can't make sense..
How do I detect when someone shakes an iPhone? http://stackoverflow.com/questions/150446/how-do-i-detect-when-someone-shakes-an-iphone into the new motion events. The main trick is that you need to have some UIView not UIViewController that you want as firstResponder to receive the shake event messages. Here's the code that you can use in any UIView to get shake events @implementation.. of the base type in IB or using it when allocating a view . In the view controller you want to set this view to become first responder void viewWillAppear BOOL animated shakeView becomeFirstResponder super viewWillAppear animated void viewWillDisappear.. shakeView resignFirstResponder super viewWillDisappear animated Don't forget that if you have other views that become first responder from user actions like a search bar or text entry field you'll also need to restore the shaking view first responder..
How to force NSLocalizedString to use a specific language http://stackoverflow.com/questions/1669645/how-to-force-nslocalizedstring-to-use-a-specific-language to determine what the user's settings for preferred languages are. This returns an array of language codes with the first one being the one set by the user for their phone and the subsequent ones used as fallbacks if a resource is not available..
Programmatically get own phone number in iOS http://stackoverflow.com/questions/193182/programmatically-get-own-phone-number-in-ios question At the risk of getting negative marks I want to suggest that the highest ranking solution currently the first response violates the latest SDK Agreement as of Nov 5 2009. Our application was just rejected for using it. Here's the..
How to take a screenshot programmatically http://stackoverflow.com/questions/2200736/how-to-take-a-screenshot-programmatically image data writeToFile @ foo.png atomically YES UPDATE April 2011 for retina display change the first line into this if UIScreen mainScreen respondsToSelector @selector scale UIGraphicsBeginImageContextWithOptions self.window.bounds.size..
Can I embed a custom font in an iPhone application? http://stackoverflow.com/questions/360751/can-i-embed-a-custom-font-in-an-iphone-application only on OS X not on iPhone. Consequently I am setting a bounty for this question and I will award the bounty to the first person who provides an answer using only documented APIs who responds with sufficient information to get this working on..
parsing HTML on the iPhone [closed] http://stackoverflow.com/questions/405749/parsing-html-on-the-iphone cells of the 2nd row of the 3rd table NSArray elements xpathParser searchWithXPathQuery @ table 3 tr 2 td Access the first cell TFHppleElement element elements objectAtIndex 0 Get the text within the cell tag NSString content element content xpathParser..
How to link to apps on the app store http://stackoverflow.com/questions/433907/how-to-link-to-apps-on-the-app-store a standard link http itunes.apple.com WebObjects MZStore.woa wa viewSoftware id 300136119 mt 8 the iphone opens safari first and then the app store. I have used other apps that open the app store directly so I know it is possible. Any ideas What..
iPhone/iOS JSON parsing tutorial [closed] http://stackoverflow.com/questions/5813077/iphone-ios-json-parsing-tutorial response and uses that response to populate the rows of a UITableView assuming it converts the JSON into an NSArray first . Anyone know of anything that might be useful iphone objective c ios json uitableview share improve this question ..
What is the best way to deal with the NSDateFormatter locale “feature”? http://stackoverflow.com/questions/6613110/what-is-the-best-way-to-deal-with-the-nsdateformatter-locale-feature en_US df setLocale loc loc release Not too bad in onsies twosies but I'm dealing with about ten different apps and the first one I look at has 43 instances of this scenario. So any clever ideas for a macro overridden class whatever to minimize the.. a macro overridden class whatever to minimize the effort to change everything without making the code to obscure My first instinct is to override NSDateFormatter with a version that would set the locale in the init method. Requires changing two..
UIDevice uniqueIdentifier Deprecated - What To Do Now? http://stackoverflow.com/questions/6993325/uidevice-uniqueidentifier-deprecated-what-to-do-now as a drop in replacement to the old UIDevice uniqueIdentifier but a UUID that is created when the app starts for the first time is what Apple seems to want you to use . Edit 3 So this major point doesn't get lost in the comment noise do not use..
HTML character decoding in Objective-C / Cocoa Touch http://stackoverflow.com/questions/1105169/html-character-decoding-in-objective-c-cocoa-touch character decoding in Objective C Cocoa Touch First of all I found this Objective C HTML escape unescape but it doesn't work for me. My encoded characters come from a RSS feed..
How would I tint an image programatically on the iPhone? http://stackoverflow.com/questions/1117211/how-would-i-tint-an-image-programatically-on-the-iphone kCGBlendModeOverlay alpha 1.0 draw image iphone cocoa touch image processing share improve this question First you'll want to subclass UIImageView and override the drawRect method. Your class needs a UIColor property let's call it..
How can I animate the movement of a view or image along a curved path? http://stackoverflow.com/questions/1142727/how-can-i-animate-the-movement-of-a-view-or-image-along-a-curved-path code to animate an image of a view into an icon to indicate saving as can be seen in the video for this application First of all import QuartzCore header file #import QuartzCore QuartzCore.h UIImageView imageViewForAnimation UIImageView alloc..
MKMapView Zoom and Region http://stackoverflow.com/questions/1166444/mkmapview-zoom-and-region a minimum maximum zoom level on a MKMapView Thanks iphone cocoa touch mapkit zoom share improve this question First of all MKMapView does not use have a predefined set of zoom levels like Google Maps does. Instead the visible area of a..
How to detect iPhone 5 (widescreen devices)? http://stackoverflow.com/questions/12446990/how-to-detect-iphone-5-widescreen-devices and then apply the view. How should I do that iphone ios objective c screen device share improve this question First of all you shouldn't rebuild all your views to fit a new screen nor use different views for different screen sizes. Use..
Programmatically Request Access to Contacts http://stackoverflow.com/questions/12648244/programmatically-request-access-to-contacts ABAddressBookRequestAccessWithCompletion addressBookRef ^ bool granted CFErrorRef error if granted First time access has been granted add the contact self _addContactToAddressBook else User denied access Display an alert telling..
Assertion failure in dequeueReusableCellWithIdentifier:forIndexPath: http://stackoverflow.com/questions/12737860/assertion-failure-in-dequeuereusablecellwithidentifierforindexpath with identifier Cell must register a nib or a class for the identifier or connect a prototype cell in a storyboard' First throw call stack 0x1c91012 0x10cee7e 0x1c90e78 0xb64f35 0xc7d14 0x39ff 0xd0f4b 0xd101f 0xb980b 0xca19b 0x6692d 0x10e26b0..
NSURLConnection and Basic HTTP Authentication http://stackoverflow.com/questions/1973325/nsurlconnection-and-basic-http-authentication server and I already have the username password so there's no need for a challenge from the server for authorization. First question 1 Does NSURLConnection have to be set as synchronous to do Basic Auth According to the answer on this post it seems..
How to store custom objects in NSUserDefaults http://stackoverflow.com/questions/2315948/how-to-store-custom-objects-in-nsuserdefaults void applicationDidFinishLaunching UIApplication application NSUserDefaults prefs NSUserDefaults standardUserDefaults First check to see if some things exist int startup prefs integerForKey @ appHasLaunched if startup nil Make the single player..
JSON and Core Data on the iPhone http://stackoverflow.com/questions/2362323/json-and-core-data-on-the-iphone so any assistance would be gratefully received. iphone objective c json core data share improve this question First pick a JSON library to use I personally like TouchJSON but several others out there are quite nice as well. The complicated..
How can I send mail from an iPhone application http://stackoverflow.com/questions/310946/how-can-i-send-mail-from-an-iphone-application class and the MFMailComposeViewControllerDelegate protocol that is tucked away in the MessageUI framework. First add the framework and import #import MessageUI MFMailComposeViewController.h Then to send a message MFMailComposeViewController..
Build fat static library (device + simulator) using Xcode and SDK 4+ http://stackoverflow.com/questions/3520977/build-fat-static-library-device-simulator-using-xcode-and-sdk-4 CONFIGURATION_TEMP_DIR echo TARGET_BUILD_DIR TARGET_BUILD_DIR fi ##################### part 1 ################## # First work out the BASESDK version number NB Apple ought to report this but they hide it # incidental searching for substrings..
iPhone App Minus App Store? http://stackoverflow.com/questions/37464/iphone-app-minus-app-store I have personally tested using the AccelerometerGraph sample app on iPhone OS 3.0. Create Self Signed Certificate First you'll need to create a self signed certificate and patch your iPhone SDK to allow the use of this certificate Launch Keychain..
iOS SDK - Programmatically generate a PDF file http://stackoverflow.com/questions/4362734/ios-sdk-programmatically-generate-a-pdf-file in an iPhone project. iphone objective c ipad ios pdf generation share improve this question A couple things... First there is a bug with CoreGraphics PDF generation in iOS that results in corrupted PDFs. I know this issue exists up to and..
Round two corners in UIView http://stackoverflow.com/questions/4847163/round-two-corners-in-uiview I've used both methods in a couple of projects last year then I hope you can find something useful. Solution 1 First of all I created this function to generate an image mask on the fly UIImage with the rounded corner I need. This function..
What's the best way to communicate between view controllers? http://stackoverflow.com/questions/569940/whats-the-best-way-to-communicate-between-view-controllers you're doing this research and seem concerned with learning how to do it right instead of just hacking it together. First I agree with the previous answers which focus on the importance of putting data in model objects when appropriate per the..
Make movie file with picture Array and song file, using AVAsset http://stackoverflow.com/questions/6061092/make-movie-file-with-picture-array-and-song-file-using-avasset movie with a picture array and an audio file. So if you want do the same thing I put my code here be careful to memory First make a movie file with your picture array use zoul's post here void writeImagesToMovieAtPath NSString path withSize CGSize..
Custom colors in UITabBar http://stackoverflow.com/questions/675433/custom-colors-in-uitabbar objective c share improve this question I found an answer to this at Silent Mac Design . I implemented this way First make a subclass of UITabBarContoller CustomUITabBarController.h #import UIKit UIKit.h @interface CustomUITabBarController..
iCloud basics and code sample [closed] http://stackoverflow.com/questions/7795629/icloud-basics-and-code-sample of how iCloud is supposed to work. When I create a new instance of an UIDocument I'll have to overwrite two methods. First BOOL loadFromContents id contents ofType NSString typeName error NSError outError to get files from the cloud and then id.. @synthesize textView _textView @synthesize document _document IBAction dismissKeyboard id sender _textView resignFirstResponder void noteDocumentContentsUpdated MyTextDocument noteDocument NSLog @ VC noteDocumentsUpdated _textView.text noteDocument.documentText..
To ARC or not to ARC? What are the pros and cons? http://stackoverflow.com/questions/8760431/to-arc-or-not-to-arc-what-are-the-pros-and-cons for knowing the Cocoa memory management rules. This is mostly true but it's important to understand why and why not. First if all of your code uses ARC and you violate the Three Magic Words all over the place you'll still have no problems. Shocking..
iOS NSXMLParsing unformed HTML http://stackoverflow.com/questions/14861674/ios-nsxmlparsing-unformed-html it can stumble through the mess to find these miniscule image links from messy html. I'm trying to retrieve ONLY the FIRST image link found in the src attribute I find in each element name called IMG in nsData that has a src attribute and then..
how to programatically set the current page for UIPageControl? http://stackoverflow.com/questions/2508227/how-to-programatically-set-the-current-page-for-uipagecontrol There is a UIPageControl there too. The UIScrollView starts off presenting page 0. What I want to do is present page 3 FIRST sometimes. How can I do this programatically. Simply setting currentPage of UIPageControl to the page number does nothing..
Build fat static library (device + simulator) using Xcode and SDK 4+ http://stackoverflow.com/questions/3520977/build-fat-static-library-device-simulator-using-xcode-and-sdk-4 your project PNG PLIST XML etc Do everything above check it works Create a new Run Script phase that comes AFTER THE FIRST ONE copy paste the code below Create a new Target in Xcode of type bundle In your MAIN PROJECT in Build Phases add the new..
how to determine load application on iphone at first time? http://stackoverflow.com/questions/4153487/how-to-determine-load-application-on-iphone-at-first-time NSLog @ this is the number i of times this app has been launched launchCount if launchCount 1 NSLog @ this is the FIRST LAUNCH of the app do stuff here as you wish bbb Blue alloc init window addSubview bbb.view if launchCount 2 NSLog @ this.. synchronize NSLog @ number of times i this app has been launched launchCount if launchCount 1 NSLog @ this is the FIRST LAUNCH of the app do stuff here as you wish if launchCount 2 NSLog @ this is the SECOND launch of the damn app do stuff..
iPhone - MPMoviePlayerController : sample code demonstrating two problems http://stackoverflow.com/questions/4535751/iphone-mpmovieplayercontroller-sample-code-demonstrating-two-problems code demonstrating two problems This is a sample code involving MPMoviePlayerController that shows two problems FIRST PROBLEM Controller vanishing To see this first problem Run the project on an iPad. select a video from the iPad library..
Lock-down iPhone/iPod/iPad so it can only run one app http://stackoverflow.com/questions/5011774/lock-down-iphone-ipod-ipad-so-it-can-only-run-one-app However note that to get your device back to normal you would need to do the following Reboot Open the settings app FIRST don't open anything else or you will need to reboot again Settings General Profiles your profile remove it. Reboot you should..
How to Parse XML File using xmlparsing on iphone? http://stackoverflow.com/questions/5715174/how-to-parse-xml-file-using-xmlparsing-on-iphone entry morerows 1 b1 entry entry c1 entry row row entry a2 xml version 1.0 encoding iso 8859 1 ADDRESS CONTACT NAME FIRST Fred LAST Bloggs NICK Bloggsie TITLE Mr STREET HOME 5 Any Street WORK Floor 24 BigShot Tower CITY HOME Little Town WORK..
|