¡@

Home 

2014/10/15 ¤U¤È 10:10:04

iphone Programming Glossary: here

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

to do it 1 Add SystemConfiguration framework to the project but don't worry about including it anywhere 2 Add Tony Million's version of Reachability.h and Reachability.m to the project found here https github.com.. it anywhere 2 Add Tony Million's version of Reachability.h and Reachability.m to the project found here https github.com tonymillion Reachability 3 Update the interface section #import Reachability.h Add.. class 1 Add SystemConfiguration framework to the project but don't worry about including it anywhere 2 Add Apple's version of Reachability.h and Reachability.m to the project you can get those here 3 Add..

iOS 6 apps - how to deal with iPhone 5 screen size? [duplicate]

http://stackoverflow.com/questions/12396545/ios-6-apps-how-to-deal-with-iphone-5-screen-size

iPhone 5 and iPhone 5 . If that sounds ugly then you could go with the default letterboxed model where the extra points pixels just show up black. Edit To enable your apps to work with iPhone 5 you need.. of the launcher image. It should be named Default 568h@2x.png . And it has to be retina quality there's no backward compatibility here You could also select this image from within Xcode. Go to the target.. be named Default 568h@2x.png . And it has to be retina quality there's no backward compatibility here You could also select this image from within Xcode. Go to the target and under the Summary section look..

How to detect iPhone 5 (widescreen devices)?

http://stackoverflow.com/questions/12446990/how-to-detect-iphone-5-widescreen-devices

UIScreen mainScreen bounds .size.height double 568 DBL_EPSILON The use of fabs with the epsilon is here to prevent precision errors when comparing floating points as pointed in the comments by H2CO3. So from..

How do I detect when someone shakes an iPhone?

http://stackoverflow.com/questions/150446/how-do-i-detect-when-someone-shakes-an-iphone

this iphone ios accelerometer shake motion detection share improve this question 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.. motion withEvent UIEvent event if event.subtype UIEventSubtypeMotionShake Put in code here to handle shake if super respondsToSelector @selector motionEnded withEvent super motionEnded motion..

How to force NSLocalizedString to use a specific language

http://stackoverflow.com/questions/1669645/how-to-force-nslocalizedstring-to-use-a-specific-language

localization internationalization share improve this question NSLocalizedString and variants thereof access the AppleLanguages key in NSUserDefaults to determine what the user's settings for preferred.. sometime early in your application's startup. You can read more about language locale preferences here Internationalization Programming Topics Getting the Current Language and Locale share improve this..

How do I apply a perspective transform to a UIView?

http://stackoverflow.com/questions/347721/how-do-i-apply-a-perspective-transform-to-a-uiview

a CATransform3D to perform the layer's rotation. The trick to get perspective working as described here is to directly access one of the matrix cells of the CATransform3D m34 . Matrix math has never been.. the layer transform from scratch for each rotation. A full example of this with code can be found here where I've implemented touch based rotation and scaling on a couple of CALayers based on an example.. transform from scratch for each rotation. A full example of this with code can be found here where I've implemented touch based rotation and scaling on a couple of CALayers based on an example by Bill..

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

EDIT failed UIFont fontWithName size experiment I downloaded Harrowprint.tff downloaded from here and added it to my Resources directory and to the project. I then tried this code UIFont font UIFont.. thrown. Looking at the TTF file in Finder confirmed that the font name was Harrowprint. EDIT there have been a number of replies so far which tell me to read the documentation on X or Y. I've experimented.. me to read the documentation on X or Y. I've experimented extensively with all of these and got nowhere. In one case X turned out to be relevant only on OS X not on iPhone. Consequently I am setting a bounty..

Fast and Lean PDF Viewer for iPhone / iPad / iOs - tips and hints?

http://stackoverflow.com/questions/3889634/fast-and-lean-pdf-viewer-for-iphone-ipad-ios-tips-and-hints

and Lean PDF Viewer for iPhone iPad iOs tips and hints There has been many Questions recently about drawing PDF's. Yes you can render PDF's very easily with a UIWebView.. limits prevents using it to create a real time render of new zoom levels. CATiledLayer Method Theres a significant Overhead time drawing a full PDF page to a CALayer individual tiles can be seen rendering.. I'm developing a PDF viewer and am rendering a UIImage of a page in a separate thread issues here too and presenting it while the scale is x1. CATiledLayer rendering kicks in once the scale is 1. iBooks..

How do I create delegates in Objective-C?

http://stackoverflow.com/questions/626898/how-do-i-create-delegates-in-objective-c

An Objective C delegate is just an object that has been assigned as a delegate of another. There's no special process for creating them you simply define a class that implements the delegate methods.. of a view it contains. To define your own delegates you'll have to declare their methods somewhere. There are two basic approaches discussed in the Apple Docs on protocols 1 An Informal Protocol This.. a view it contains. To define your own delegates you'll have to declare their methods somewhere. There are two basic approaches discussed in the Apple Docs on protocols 1 An Informal Protocol This can be..

How do I record audio on iPhone with AVAudioRecorder?

http://stackoverflow.com/questions/1010343/how-do-i-record-audio-on-iphone-with-avaudiorecorder

but I want to use AVAudioRecorder and not the older way of recording like the example SpeakHere shows. There are not any examples of how to best do this in the iPhone Dev Center and only reference.. iphone audio recording share improve this question Actually there are no examples at all. Here is my working code. Recording is triggered by the user pressing a button on the navBar. The recording..

How to make a UITextField move up when keyboard is present

http://stackoverflow.com/questions/1126726/how-to-make-a-uitextfield-move-up-when-keyboard-is-present

the standard way is to move up down the view having textfields whenever the keyboard is shown. Here is some sample code #define kOFFSET_FOR_KEYBOARD 80.0 void keyboardWillShow Animate the current view..

Programmatically Request Access to Contacts

http://stackoverflow.com/questions/12648244/programmatically-request-access-to-contacts

of the page access to the address book must be granted before it can be access programmatically. Here is what I ended up doing. #import AddressBookUI AddressBookUI.h Request authorization to Address Book..

How do I wrap text in a UITableViewCell without a custom cell

http://stackoverflow.com/questions/129502/how-do-i-wrap-text-in-a-uitableviewcell-without-a-custom-cell

in heightForRowAtIndexPath . iphone objective c cocoa touch share improve this question Here is a simpler way and it works for me Inside your cellForRowAtIndexPath function. The first time you..

How to store custom objects in NSUserDefaults

http://stackoverflow.com/questions/2315948/how-to-store-custom-objects-in-nsuserdefaults

doesn't give any errors. Perhaps I'm missing something basic and I'm just too tired but we'll see. Here is the implementation of my Custom class Player @interface Player NSObject NSString name NSNumber life..

This class is not key value coding-compliant for the key

http://stackoverflow.com/questions/3088059/this-class-is-not-key-value-coding-compliant-for-the-key

on the label screen with the error this class is not key value coding compliant for the key XXXX . Here is the code in SecondView.h . @interface SecondView UIViewController IBOutlet UILabel string @property.. UIViewController IBOutlet UILabel string @property nonatomic retain IBOutlet UILabel string @end Here is the code in SecondView.m Almost nothing in there apart from the auto generated code which I don't..

Turn on torch/flash on iPhone 4

http://stackoverflow.com/questions/3190034/turn-on-torch-flash-on-iphone-4

and keep it on on iPhone 4 is by turning the video camera on. I'm not too sure of the code though. Here is what I am trying IBAction turnTorchOn AVCaptureSession captureSession AVCaptureSession alloc init..

Bold & Non-Bold Text In A Single UILabel?

http://stackoverflow.com/questions/3586871/bold-non-bold-text-in-a-single-uilabel

Set it in our UILabel and we are done _label setAttributedText attributedText else iOS5 and below Here we have some options too. The first one is to do something less fancy and show it just as plain text..

Fast and Lean PDF Viewer for iPhone / iPad / iOs - tips and hints?

http://stackoverflow.com/questions/3889634/fast-and-lean-pdf-viewer-for-iphone-ipad-ios-tips-and-hints

Dest array Getting a table of contents Document title and Keywords Getting Raw Text and here and Here and here positioning focused Searching and here doesn't work with all PDFs some just show weird characters..

How do you beta test an iphone app?

http://stackoverflow.com/questions/40154/how-do-you-beta-test-an-iphone-app

in Finder . Zip the .app file and the .mobileprovision file and send the archive to your tester. Here is my app. To install it onto your phone Unzip the archive file. Open iTunes. Drag both files into iTunes..

iPhone app in landscape mode

http://stackoverflow.com/questions/402/iphone-app-in-landscape-mode

Exciting news As discovered by Andrew below This problem has been fixed by Apple in 4.0 . Here is a FULL TEST PROJECT you can download that shows it working correctly in a Landscape only iPad app...

How to filter NSFetchedResultsController (CoreData) with UISearchDisplayController/UISearchBar

http://stackoverflow.com/questions/4471289/how-to-filter-nsfetchedresultscontroller-coredata-with-uisearchdisplaycontroll

too much code. I'm confused because so many of the examples are array based instead of CoreData. Here are some questions Do I need to have a second NSFetchedResultsController that retrieves only the matching.. FRC and you will see exceptions thrown about incorrect number of sections or rows in sections. Here is what I did I have two FRCs available as properties fetchedResultsController and searchFetchedResultsController...

Subclass UIButton to add a property

http://stackoverflow.com/questions/5500327/subclass-uibutton-to-add-a-property

I'd like to subclass UIButton to add some properties that i need not methods... only properties . Here the code of my subclass .h @interface MyButton UIButton MyPropertyType property @property nonatomic..

Understanding reference counting with Cocoa and Objective-C

http://stackoverflow.com/questions/6578/understanding-reference-counting-with-cocoa-and-objective-c

return s autorelease I realize all of this is a bit confusing at some point though it will click. Here are a few references to get you going Apple's introduction to memory management. Cocoa Programming for..

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

by mid day Tuesday. See below deadline extended. Update Re OMZ's proposal here is what I'm finding Here is the category version h file #import Foundation Foundation.h @interface NSDateFormatter Locale id..

Is it possible to target older iOS versions when using Xcode 4.2 and iOS 5 SDK?

http://stackoverflow.com/questions/7760946/is-it-possible-to-target-older-ios-versions-when-using-xcode-4-2-and-ios-5-sdk

the same issue trying to get a newly created Xcode 4.2 project running on an iPhone 3G 4.2.1. Here is how I was able to get it to run. 1 Change the Target's Build Settings Architecture from Standard..

How to use NSJSONSerialization

http://stackoverflow.com/questions/8356842/how-to-use-nsjsonserialization

keys id 1 and name Aaa . I do not understand how the NSJSONSerialization stores the data though. Here is my code so far NSError e nil NSDictionary JSON NSJSONSerialization JSONObjectWithData data options..

Having trouble adding objects to NSMutableArray in Objective C

http://stackoverflow.com/questions/851926/having-trouble-adding-objects-to-nsmutablearray-in-objective-c

to NSMutableArray viewedCardsArray however without breaking it does not get added to the array. Here is the code. Inside the header file Class.h @interface MyViewController UIViewController NSMutableArray..

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

METHOD 1 Use a simple ARC and GCD compatible class to do it 1 Add SystemConfiguration framework to the project but don't worry about including it anywhere 2 Add Tony Million's version of Reachability.h and Reachability.m to the project found here https github.com tonymillion Reachability 3 Update the interface section.. framework to the project but don't worry about including it anywhere 2 Add Tony Million's version of Reachability.h and Reachability.m to the project found here https github.com tonymillion Reachability 3 Update the interface section #import Reachability.h Add this to the interface in the .m file of your view controller.. Do it yourself the old way using Apple's outdated Reachability class 1 Add SystemConfiguration framework to the project but don't worry about including it anywhere 2 Add Apple's version of Reachability.h and Reachability.m to the project you can get those here 3 Add @class Reachability to the .h file of where you are implementing..

iOS 6 apps - how to deal with iPhone 5 screen size? [duplicate]

http://stackoverflow.com/questions/12396545/ios-6-apps-how-to-deal-with-iphone-5-screen-size

then the only remaining option is to have two UIs pre iPhone 5 and iPhone 5 . If that sounds ugly then you could go with the default letterboxed model where the extra points pixels just show up black. Edit To enable your apps to work with iPhone 5 you need to add a retina version of the launcher image. It should be.. apps to work with iPhone 5 you need to add a retina version of the launcher image. It should be named Default 568h@2x.png . And it has to be retina quality there's no backward compatibility here You could also select this image from within Xcode. Go to the target and under the Summary section look for Launch Images. The.. need to add a retina version of the launcher image. It should be named Default 568h@2x.png . And it has to be retina quality there's no backward compatibility here You could also select this image from within Xcode. Go to the target and under the Summary section look for Launch Images. The image has to be 640x1136 pixels in..

How to detect iPhone 5 (widescreen devices)?

http://stackoverflow.com/questions/12446990/how-to-detect-iphone-5-widescreen-devices

to simplify all of this #define IS_IPHONE_5 fabs double UIScreen mainScreen bounds .size.height double 568 DBL_EPSILON The use of fabs with the epsilon is here to prevent precision errors when comparing floating points as pointed in the comments by H2CO3. So from now on you can use it in standard if else statements if..

How do I detect when someone shakes an iPhone?

http://stackoverflow.com/questions/150446/how-do-i-detect-when-someone-shakes-an-iphone

about for a split second. Does anyone know how to detect this iphone ios accelerometer shake motion detection share improve this question 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.. events @implementation ShakingView void motionEnded UIEventSubtype motion withEvent UIEvent event if event.subtype UIEventSubtypeMotionShake Put in code here to handle shake if super respondsToSelector @selector motionEnded withEvent super motionEnded motion withEvent event BOOL canBecomeFirstResponder return YES @end..

How to force NSLocalizedString to use a specific language

http://stackoverflow.com/questions/1669645/how-to-force-nslocalizedstring-to-use-a-specific-language

different language than the device iphone objective c cocoa localization internationalization share improve this question NSLocalizedString and variants thereof access the AppleLanguages key in NSUserDefaults to determine what the user's settings for preferred languages are. This returns an array of language codes with..

How do I apply a perspective transform to a UIView?

http://stackoverflow.com/questions/347721/how-do-i-apply-a-perspective-transform-to-a-uiview

Ben said you'll need to work with the UIView's layer using a CATransform3D to perform the layer's rotation. The trick to get perspective working as described here is to directly access one of the matrix cells of the CATransform3D m34 . Matrix math has never been my thing so I can't explain exactly why this works but it does... rotationAndPerspectiveTransform which rebuilds the layer transform from scratch for each rotation. A full example of this with code can be found here where I've implemented touch based rotation and scaling on a couple of CALayers based on an example by Bill Dudney. The newest version of the program at the very.. rotationAndPerspectiveTransform which rebuilds the layer transform from scratch for each rotation. A full example of this with code can be found here where I've implemented touch based rotation and scaling on a couple of CALayers based on an example by Bill Dudney. The newest version of the program at the very bottom..

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

but without justification so I'm looking for a definitive answer. EDIT failed UIFont fontWithName size experiment I downloaded Harrowprint.tff downloaded from here and added it to my Resources directory and to the project. I then tried this code UIFont font UIFont fontWithName @ Harrowprint size 20 which resulted in an exception.. @ Harrowprint size 20 which resulted in an exception being thrown. Looking at the TTF file in Finder confirmed that the font name was Harrowprint. EDIT there have been a number of replies so far which tell me to read the documentation on X or Y. I've experimented extensively with all of these and got nowhere. In one.. EDIT there have been a number of replies so far which tell me to read the documentation on X or Y. I've experimented extensively with all of these and got nowhere. 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..

Fast and Lean PDF Viewer for iPhone / iPad / iOs - tips and hints?

http://stackoverflow.com/questions/3889634/fast-and-lean-pdf-viewer-for-iphone-ipad-ios-tips-and-hints

and Lean PDF Viewer for iPhone iPad iOs tips and hints There has been many Questions recently about drawing PDF's. Yes you can render PDF's very easily with a UIWebView but this cant give the performance and functionality.. CPU and memory hit on generating the UIImages from a PDFcontext limits prevents using it to create a real time render of new zoom levels. CATiledLayer Method Theres a significant Overhead time drawing a full PDF page to a CALayer individual tiles can be seen rendering even with a tileSize tweak CALayers cant be prepared ahead.. usage of apple's zoomable PDF example. In my current project I'm developing a PDF viewer and am rendering a UIImage of a page in a separate thread issues here too and presenting it while the scale is x1. CATiledLayer rendering kicks in once the scale is 1. iBooks takes a similar double take approach as if you scroll the..

How do I create delegates in Objective-C?

http://stackoverflow.com/questions/626898/how-do-i-create-delegates-in-objective-c

ios objective c cocoa delegates share improve this question An Objective C delegate is just an object that has been assigned as a delegate of another. There's no special process for creating them you simply define a class that implements the delegate methods you're interested in. Though with delegates that use a formal.. that object. For example a view controller is often the delegate of a view it contains. To define your own delegates you'll have to declare their methods somewhere. There are two basic approaches discussed in the Apple Docs on protocols 1 An Informal Protocol This can be done as NSWindow does in a category on NSObject. For.. For example a view controller is often the delegate of a view it contains. To define your own delegates you'll have to declare their methods somewhere. There are two basic approaches discussed in the Apple Docs on protocols 1 An Informal Protocol This can be done as NSWindow does in a category on NSObject. For example..

How do I record audio on iPhone with AVAudioRecorder?

http://stackoverflow.com/questions/1010343/how-do-i-record-audio-on-iphone-with-avaudiorecorder

playing with the 3.0 sdk. I want to record audio in my application but I want to use AVAudioRecorder and not the older way of recording like the example SpeakHere shows. There are not any examples of how to best do this in the iPhone Dev Center and only reference to the classes. I am a newbie at iPhone development so I am.. for a simple sample to get me started. Thanks in advance. iphone audio recording share improve this question Actually there are no examples at all. Here is my working code. Recording is triggered by the user pressing a button on the navBar. The recording uses cd quality 44100 samples stereo 2 channels linear pcm...

How to make a UITextField move up when keyboard is present

http://stackoverflow.com/questions/1126726/how-to-make-a-uitextfield-move-up-when-keyboard-is-present

For showing the textfields without being hidden by the keyboard the standard way is to move up down the view having textfields whenever the keyboard is shown. Here is some sample code #define kOFFSET_FOR_KEYBOARD 80.0 void keyboardWillShow Animate the current view out of the way if self.view.frame.origin.y 0 self setViewMovedUp..

Programmatically Request Access to Contacts

http://stackoverflow.com/questions/12648244/programmatically-request-access-to-contacts

on apple's site scroll down to Privacy in the middle of the page access to the address book must be granted before it can be access programmatically. Here is what I ended up doing. #import AddressBookUI AddressBookUI.h Request authorization to Address Book ABAddressBookRef addressBookRef ABAddressBookCreateWithOptions..

How do I wrap text in a UITableViewCell without a custom cell

http://stackoverflow.com/questions/129502/how-do-i-wrap-text-in-a-uitableviewcell-without-a-custom-cell

text to display I'm just returning a large value for the height in heightForRowAtIndexPath . iphone objective c cocoa touch share improve this question Here is a simpler way and it works for me Inside your cellForRowAtIndexPath function. The first time you create your cell UITableViewCell cell tableView dequeueReusableCellWithIdentifier..

How to store custom objects in NSUserDefaults

http://stackoverflow.com/questions/2315948/how-to-store-custom-objects-in-nsuserdefaults

the code crashes now and I'm not sure why because it doesn't give any errors. Perhaps I'm missing something basic and I'm just too tired but we'll see. Here is the implementation of my Custom class Player @interface Player NSObject NSString name NSNumber life Log of player's life Getting functions return the info NSString..

This class is not key value coding-compliant for the key

http://stackoverflow.com/questions/3088059/this-class-is-not-key-value-coding-compliant-for-the-key

in my class. Every time I build my application it crashes on the label screen with the error this class is not key value coding compliant for the key XXXX . Here is the code in SecondView.h . @interface SecondView UIViewController IBOutlet UILabel string @property nonatomic retain IBOutlet UILabel string @end Here is the.. . Here is the code in SecondView.h . @interface SecondView UIViewController IBOutlet UILabel string @property nonatomic retain IBOutlet UILabel string @end Here is the code in SecondView.m Almost nothing in there apart from the auto generated code which I don't paste here . @implementation SecondView @synthesize string..

Turn on torch/flash on iPhone 4

http://stackoverflow.com/questions/3190034/turn-on-torch-flash-on-iphone-4

on iPhone 4 I know that the only way to turn on the flash and keep it on on iPhone 4 is by turning the video camera on. I'm not too sure of the code though. Here is what I am trying IBAction turnTorchOn AVCaptureSession captureSession AVCaptureSession alloc init AVCaptureDevice videoCaptureDevice AVCaptureDevice defaultDeviceWithMediaType..

Bold & Non-Bold Text In A Single UILabel?

http://stackoverflow.com/questions/3586871/bold-non-bold-text-in-a-single-uilabel

attrs attributedText setAttributes subAttrs range range Set it in our UILabel and we are done _label setAttributedText attributedText else iOS5 and below Here we have some options too. The first one is to do something less fancy and show it just as plain text without attributes. The second is to use CoreText and get similar..

Fast and Lean PDF Viewer for iPhone / iPad / iOs - tips and hints?

http://stackoverflow.com/questions/3889634/fast-and-lean-pdf-viewer-for-iphone-ipad-ios-tips-and-hints

the target of the link Getting the page number from the Dest array Getting a table of contents Document title and Keywords Getting Raw Text and here and Here and here positioning focused Searching and here doesn't work with all PDFs some just show weird characters I guess it's an encoding issue but I'm not sure Credit..

How do you beta test an iphone app?

http://stackoverflow.com/questions/40154/how-do-you-beta-test-an-iphone-app

Products and expand it. Right click the app and select Reveal in Finder . Zip the .app file and the .mobileprovision file and send the archive to your tester. Here is my app. To install it onto your phone Unzip the archive file. Open iTunes. Drag both files into iTunes and drop them on the Library group. Sync your phone to..

iPhone app in landscape mode

http://stackoverflow.com/questions/402/iphone-app-in-landscape-mode

Builder. iphone objective c share improve this question Exciting news As discovered by Andrew below This problem has been fixed by Apple in 4.0 . Here is a FULL TEST PROJECT you can download that shows it working correctly in a Landscape only iPad app. LandscapeOnlyProblemTest It would appear it is NO longer necessary..

How to filter NSFetchedResultsController (CoreData) with UISearchDisplayController/UISearchBar

http://stackoverflow.com/questions/4471289/how-to-filter-nsfetchedresultscontroller-coredata-with-uisearchdisplaycontroll

I want to make sure I'm on the right path before I change too much code. I'm confused because so many of the examples are array based instead of CoreData. Here are some questions Do I need to have a second NSFetchedResultsController that retrieves only the matching items or can I use the same one as the primary TableView.. and try to incorrectly use the filtered version of your FRC and you will see exceptions thrown about incorrect number of sections or rows in sections. Here is what I did I have two FRCs available as properties fetchedResultsController and searchFetchedResultsController. The searchFetchedResultsController should not..

Subclass UIButton to add a property

http://stackoverflow.com/questions/5500327/subclass-uibutton-to-add-a-property

UIButton to add a property I'd like to subclass UIButton to add some properties that i need not methods... only properties . Here the code of my subclass .h @interface MyButton UIButton MyPropertyType property @property nonatomic retain MyPropertyType property @end .m @implementation MyButton..

Understanding reference counting with Cocoa and Objective-C

http://stackoverflow.com/questions/6578/understanding-reference-counting-with-cocoa-and-objective-c

string will still be valid for the caller of this function. return s autorelease I realize all of this is a bit confusing at some point though it will click. Here are a few references to get you going Apple's introduction to memory management. Cocoa Programming for Mac OS X 4th Edition by Aaron Hillegas a very well written..

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

the bounty to the best legitimate suggestion critique I see by mid day Tuesday. See below deadline extended. Update Re OMZ's proposal here is what I'm finding Here is the category version h file #import Foundation Foundation.h @interface NSDateFormatter Locale id initWithSafeLocale @end Category m file #import NSDateFormatter..

Is it possible to target older iOS versions when using Xcode 4.2 and iOS 5 SDK?

http://stackoverflow.com/questions/7760946/is-it-possible-to-target-older-ios-versions-when-using-xcode-4-2-and-ios-5-sdk

iphone xcode ios5 share improve this question I was having the same issue trying to get a newly created Xcode 4.2 project running on an iPhone 3G 4.2.1. Here is how I was able to get it to run. 1 Change the Target's Build Settings Architecture from Standard armv7 to other . Add armv6 and armv7. 2 Change the Target's..

How to use NSJSONSerialization

http://stackoverflow.com/questions/8356842/how-to-use-nsjsonserialization

so the 0th element in the array is a dictionary with keys id 1 and name Aaa . I do not understand how the NSJSONSerialization stores the data though. Here is my code so far NSError e nil NSDictionary JSON NSJSONSerialization JSONObjectWithData data options NSJSONReadingMutableContainers error e This is just something..

Having trouble adding objects to NSMutableArray in Objective C

http://stackoverflow.com/questions/851926/having-trouble-adding-objects-to-nsmutablearray-in-objective-c

NSMutableArray instance variable. I tried adding NSNumber card to NSMutableArray viewedCardsArray however without breaking it does not get added to the array. Here is the code. Inside the header file Class.h @interface MyViewController UIViewController NSMutableArray viewedCardsArray snip ... @property nonatomic retain..

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

compatible class to do it 1 Add SystemConfiguration framework to the project but don't worry about including it anywhere 2 Add Tony Million's version of Reachability.h and Reachability.m to the project found here https github.com tonymillion.. about including it anywhere 2 Add Tony Million's version of Reachability.h and Reachability.m to the project found here https github.com tonymillion Reachability 3 Update the interface section #import Reachability.h Add this to the interface.. outdated Reachability class 1 Add SystemConfiguration framework to the project but don't worry about including it anywhere 2 Add Apple's version of Reachability.h and Reachability.m to the project you can get those here 3 Add @class Reachability..

iOS 6 apps - how to deal with iPhone 5 screen size? [duplicate]

http://stackoverflow.com/questions/12396545/ios-6-apps-how-to-deal-with-iphone-5-screen-size

to have two UIs pre iPhone 5 and iPhone 5 . If that sounds ugly then you could go with the default letterboxed model where the extra points pixels just show up black. Edit To enable your apps to work with iPhone 5 you need to add a retina version.. add a retina version of the launcher image. It should be named Default 568h@2x.png . And it has to be retina quality there's no backward compatibility here You could also select this image from within Xcode. Go to the target and under the Summary.. image. It should be named Default 568h@2x.png . And it has to be retina quality there's no backward compatibility here You could also select this image from within Xcode. Go to the target and under the Summary section look for Launch Images...

How to detect iPhone 5 (widescreen devices)?

http://stackoverflow.com/questions/12446990/how-to-detect-iphone-5-widescreen-devices

fabs double UIScreen mainScreen bounds .size.height double 568 DBL_EPSILON The use of fabs with the epsilon is here to prevent precision errors when comparing floating points as pointed in the comments by H2CO3. So from now on you can use..

How do I detect when someone shakes an iPhone?

http://stackoverflow.com/questions/150446/how-do-i-detect-when-someone-shakes-an-iphone

know how to detect this iphone ios accelerometer shake motion detection share improve this question 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.. void motionEnded UIEventSubtype motion withEvent UIEvent event if event.subtype UIEventSubtypeMotionShake Put in code here to handle shake if super respondsToSelector @selector motionEnded withEvent super motionEnded motion withEvent event BOOL..

How to force NSLocalizedString to use a specific language

http://stackoverflow.com/questions/1669645/how-to-force-nslocalizedstring-to-use-a-specific-language

objective c cocoa localization internationalization share improve this question NSLocalizedString and variants thereof access the AppleLanguages key in NSUserDefaults to determine what the user's settings for preferred languages are. This..

How do I apply a perspective transform to a UIView?

http://stackoverflow.com/questions/347721/how-do-i-apply-a-perspective-transform-to-a-uiview

layer using a CATransform3D to perform the layer's rotation. The trick to get perspective working as described here is to directly access one of the matrix cells of the CATransform3D m34 . Matrix math has never been my thing so I can't.. which rebuilds the layer transform from scratch for each rotation. A full example of this with code can be found here where I've implemented touch based rotation and scaling on a couple of CALayers based on an example by Bill Dudney. The.. which rebuilds the layer transform from scratch for each rotation. A full example of this with code can be found here where I've implemented touch based rotation and scaling on a couple of CALayers based on an example by Bill Dudney. The newest..

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

for a definitive answer. EDIT failed UIFont fontWithName size experiment I downloaded Harrowprint.tff downloaded from here and added it to my Resources directory and to the project. I then tried this code UIFont font UIFont fontWithName @ Harrowprint.. in an exception being thrown. Looking at the TTF file in Finder confirmed that the font name was Harrowprint. EDIT there have been a number of replies so far which tell me to read the documentation on X or Y. I've experimented extensively with.. so far which tell me to read the documentation on X or Y. I've experimented extensively with all of these and got nowhere. 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..

Fast and Lean PDF Viewer for iPhone / iPad / iOs - tips and hints?

http://stackoverflow.com/questions/3889634/fast-and-lean-pdf-viewer-for-iphone-ipad-ios-tips-and-hints

and Lean PDF Viewer for iPhone iPad iOs tips and hints There has been many Questions recently about drawing PDF's. Yes you can render PDF's very easily with a UIWebView but this cant.. from a PDFcontext limits prevents using it to create a real time render of new zoom levels. CATiledLayer Method Theres a significant Overhead time drawing a full PDF page to a CALayer individual tiles can be seen rendering even with a tileSize.. In my current project I'm developing a PDF viewer and am rendering a UIImage of a page in a separate thread issues here too and presenting it while the scale is x1. CATiledLayer rendering kicks in once the scale is 1. iBooks takes a similar..

How do I create delegates in Objective-C?

http://stackoverflow.com/questions/626898/how-do-i-create-delegates-in-objective-c

improve this question An Objective C delegate is just an object that has been assigned as a delegate of another. There's no special process for creating them you simply define a class that implements the delegate methods you're interested.. is often the delegate of a view it contains. To define your own delegates you'll have to declare their methods somewhere. There are two basic approaches discussed in the Apple Docs on protocols 1 An Informal Protocol This can be done as NSWindow.. the delegate of a view it contains. To define your own delegates you'll have to declare their methods somewhere. There are two basic approaches discussed in the Apple Docs on protocols 1 An Informal Protocol This can be done as NSWindow does..

How do I record audio on iPhone with AVAudioRecorder?

http://stackoverflow.com/questions/1010343/how-do-i-record-audio-on-iphone-with-avaudiorecorder

audio in my application but I want to use AVAudioRecorder and not the older way of recording like the example SpeakHere shows. There are not any examples of how to best do this in the iPhone Dev Center and only reference to the classes. I am.. Thanks in advance. iphone audio recording share improve this question Actually there are no examples at all. Here is my working code. Recording is triggered by the user pressing a button on the navBar. The recording uses cd quality 44100..

How to make a UITextField move up when keyboard is present

http://stackoverflow.com/questions/1126726/how-to-make-a-uitextfield-move-up-when-keyboard-is-present

hidden by the keyboard the standard way is to move up down the view having textfields whenever the keyboard is shown. Here is some sample code #define kOFFSET_FOR_KEYBOARD 80.0 void keyboardWillShow Animate the current view out of the way if self.view.frame.origin.y..

Programmatically Request Access to Contacts

http://stackoverflow.com/questions/12648244/programmatically-request-access-to-contacts

Privacy in the middle of the page access to the address book must be granted before it can be access programmatically. Here is what I ended up doing. #import AddressBookUI AddressBookUI.h Request authorization to Address Book ABAddressBookRef addressBookRef..

How do I wrap text in a UITableViewCell without a custom cell

http://stackoverflow.com/questions/129502/how-do-i-wrap-text-in-a-uitableviewcell-without-a-custom-cell

value for the height in heightForRowAtIndexPath . iphone objective c cocoa touch share improve this question Here is a simpler way and it works for me Inside your cellForRowAtIndexPath function. The first time you create your cell UITableViewCell..

How to store custom objects in NSUserDefaults

http://stackoverflow.com/questions/2315948/how-to-store-custom-objects-in-nsuserdefaults

sure why because it doesn't give any errors. Perhaps I'm missing something basic and I'm just too tired but we'll see. Here is the implementation of my Custom class Player @interface Player NSObject NSString name NSNumber life Log of player's life..

This class is not key value coding-compliant for the key

http://stackoverflow.com/questions/3088059/this-class-is-not-key-value-coding-compliant-for-the-key

it crashes on the label screen with the error this class is not key value coding compliant for the key XXXX . Here is the code in SecondView.h . @interface SecondView UIViewController IBOutlet UILabel string @property nonatomic retain.. @interface SecondView UIViewController IBOutlet UILabel string @property nonatomic retain IBOutlet UILabel string @end Here is the code in SecondView.m Almost nothing in there apart from the auto generated code which I don't paste here . @implementation..

Turn on torch/flash on iPhone 4

http://stackoverflow.com/questions/3190034/turn-on-torch-flash-on-iphone-4

turn on the flash and keep it on on iPhone 4 is by turning the video camera on. I'm not too sure of the code though. Here is what I am trying IBAction turnTorchOn AVCaptureSession captureSession AVCaptureSession alloc init AVCaptureDevice videoCaptureDevice..

Bold & Non-Bold Text In A Single UILabel?

http://stackoverflow.com/questions/3586871/bold-non-bold-text-in-a-single-uilabel

subAttrs range range Set it in our UILabel and we are done _label setAttributedText attributedText else iOS5 and below Here we have some options too. The first one is to do something less fancy and show it just as plain text without attributes...

Fast and Lean PDF Viewer for iPhone / iPad / iOs - tips and hints?

http://stackoverflow.com/questions/3889634/fast-and-lean-pdf-viewer-for-iphone-ipad-ios-tips-and-hints

page number from the Dest array Getting a table of contents Document title and Keywords Getting Raw Text and here and Here and here positioning focused Searching and here doesn't work with all PDFs some just show weird characters I guess it's..

How do you beta test an iphone app?

http://stackoverflow.com/questions/40154/how-do-you-beta-test-an-iphone-app

app and select Reveal in Finder . Zip the .app file and the .mobileprovision file and send the archive to your tester. Here is my app. To install it onto your phone Unzip the archive file. Open iTunes. Drag both files into iTunes and drop them..

iPhone app in landscape mode

http://stackoverflow.com/questions/402/iphone-app-in-landscape-mode

improve this question Exciting news As discovered by Andrew below This problem has been fixed by Apple in 4.0 . Here is a FULL TEST PROJECT you can download that shows it working correctly in a Landscape only iPad app. LandscapeOnlyProblemTest..

How to filter NSFetchedResultsController (CoreData) with UISearchDisplayController/UISearchBar

http://stackoverflow.com/questions/4471289/how-to-filter-nsfetchedresultscontroller-coredata-with-uisearchdisplaycontroll

path before I change too much code. I'm confused because so many of the examples are array based instead of CoreData. Here are some questions Do I need to have a second NSFetchedResultsController that retrieves only the matching items or can I.. version of your FRC and you will see exceptions thrown about incorrect number of sections or rows in sections. Here is what I did I have two FRCs available as properties fetchedResultsController and searchFetchedResultsController. The searchFetchedResultsController..

Subclass UIButton to add a property

http://stackoverflow.com/questions/5500327/subclass-uibutton-to-add-a-property

to add a property I'd like to subclass UIButton to add some properties that i need not methods... only properties . Here the code of my subclass .h @interface MyButton UIButton MyPropertyType property @property nonatomic retain MyPropertyType..

Understanding reference counting with Cocoa and Objective-C

http://stackoverflow.com/questions/6578/understanding-reference-counting-with-cocoa-and-objective-c

of this function. return s autorelease I realize all of this is a bit confusing at some point though it will click. Here are a few references to get you going Apple's introduction to memory management. Cocoa Programming for Mac OS X 4th Edition..

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

critique I see by mid day Tuesday. See below deadline extended. Update Re OMZ's proposal here is what I'm finding Here is the category version h file #import Foundation Foundation.h @interface NSDateFormatter Locale id initWithSafeLocale @end..

Is it possible to target older iOS versions when using Xcode 4.2 and iOS 5 SDK?

http://stackoverflow.com/questions/7760946/is-it-possible-to-target-older-ios-versions-when-using-xcode-4-2-and-ios-5-sdk

question I was having the same issue trying to get a newly created Xcode 4.2 project running on an iPhone 3G 4.2.1. Here is how I was able to get it to run. 1 Change the Target's Build Settings Architecture from Standard armv7 to other . Add..

How to use NSJSONSerialization

http://stackoverflow.com/questions/8356842/how-to-use-nsjsonserialization

is a dictionary with keys id 1 and name Aaa . I do not understand how the NSJSONSerialization stores the data though. Here is my code so far NSError e nil NSDictionary JSON NSJSONSerialization JSONObjectWithData data options NSJSONReadingMutableContainers..

Having trouble adding objects to NSMutableArray in Objective C

http://stackoverflow.com/questions/851926/having-trouble-adding-objects-to-nsmutablearray-in-objective-c

adding NSNumber card to NSMutableArray viewedCardsArray however without breaking it does not get added to the array. Here is the code. Inside the header file Class.h @interface MyViewController UIViewController NSMutableArray viewedCardsArray..

How to post more parameters with image upload code in iOS?

http://stackoverflow.com/questions/10618056/how-to-post-more-parameters-with-image-upload-code-in-ios

#import AFHTTPClient.h #import AFHTTPRequestOperation.h #import SBJson.h NSString const APIKey @ APIKEY GOES HERE IF YOU WANT TO USE ONE @implementation NetworkClient void processURLRequestWithURL NSString url andParams NSDictionary..

cocos2d 2.0-rc2: end the director and restart

http://stackoverflow.com/questions/11037134/cocos2d-2-0-rc2-end-the-director-and-restart

depthFormat 0 GL_DEPTH_COMPONENT24_OES preserveBackbuffer NO sharegroup nil multiSampling NO numberOfSamples 0 HERE YOU CHECK TO SEE IF THERE IS A SCENE RUNNING IN THE DIRECTOR ALREADY if director_ runningScene director_ setView glView.. preserveBackbuffer NO sharegroup nil multiSampling NO numberOfSamples 0 HERE YOU CHECK TO SEE IF THERE IS A SCENE RUNNING IN THE DIRECTOR ALREADY if director_ runningScene director_ setView glView SET THE DIRECTOR VIEW if director_.. ENABLE RETINA CCLOG @ Retina Display Not supported director_ runWithScene HelloWorldLayer scene RUN THE SCENE else THERE IS A SCENE START SINCE IT WAS STOPPED AND REPLACE TO RESTART director_ startAnimation director_ replaceScene HelloWorldLayer..

iphone: secure restfull server "The certificate for this server is invalid

http://stackoverflow.com/questions/12347410/iphone-secure-restfull-server-the-certificate-for-this-server-is-invalid

^ NSURLResponse response NSData data NSError error if data length 0 error nil NSLog @ Data @ data DO YOUR WORK HERE else if data length 0 error nil NSLog @ Nothing was downloaded. else if error nil NSLog @ Error @ error BOOL connection..

CallStateDisconnected only detected for incoming calls, not for calls made from my app

http://stackoverflow.com/questions/13553635/callstatedisconnected-only-detected-for-incoming-calls-not-for-calls-made-from

in our call center NSDictionary dict NSDictionary dictionaryWithObject call.callState forKey @ callState BREAKPOINT HERE NSNotificationCenter defaultCenter postNotificationName @ CTCallStateDidChange object self userInfo dict Strange thing is..

Core-Data iPhone: could not locate an NSManagedObjectModel

http://stackoverflow.com/questions/1632497/core-data-iphone-could-not-locate-an-nsmanagedobjectmodel

addButton addButton release NSLog @ 3 viewDidLoad RootViewController NSError error HERE IS THE CRASH SITE if self fetchedResultsController performFetch error NSLog @ Does not reach this point in viewDidLoad RootViewController..

Accessing Method from other Classes Objective-C

http://stackoverflow.com/questions/1658433/accessing-method-from-other-classes-objective-c

me to give you one. File ViewController1.m @implementation ViewController1 Do Some awesome stuff.... CALL CommonMethod HERE @end File ViewController2.m @implementation ViewController2 Do Some awesome stuff.... CALL CommonMethod HERE @end File CommonClass.. HERE @end File ViewController2.m @implementation ViewController2 Do Some awesome stuff.... CALL CommonMethod HERE @end File CommonClass @implementation commonClass void CommonMethod id sender So some awesome generic stuff... @end I feel..

What exactly must I do in viewDidUnload?

http://stackoverflow.com/questions/2261972/what-exactly-must-i-do-in-viewdidunload

from memory. And if I have subviews attached to the main view of the view controller I have to release that stuff only HERE but not in dealloc as well That's confusing. Also what if dealloc causes the view to be unloaded released Then again it..

How to download a text file with iPhone SDK?

http://stackoverflow.com/questions/2308159/how-to-download-a-text-file-with-iphone-sdk

stringWithContentsOfURL NSURL URLWithString url encoding NSUTF8StringEncoding error err if err nil HANDLE ERROR HERE Then to save it you can use NSUserDefaults standardUserDefaults setObject myTxtFile forKey @ MyFile And to retrieve it NSString..

UIToolbar tint on iOS 4

http://stackoverflow.com/questions/3151549/uitoolbar-tint-on-ios-4

before the upgrade and was written like this Toolbar content NSArray items NSArray arrayWithObjects ... PSEUDO CODE HERE toolbar setItems items Add tint toolbar.tintColor UIColor colorWithRed 0.83 green 0.43 blue 0.57 alpha 0.5 What I needed.. 0.83 green 0.43 blue 0.57 alpha 0.5 Toolbar content NSArray items NSArray arrayWithObjects ... PSEUDO CODE HERE toolbar setItems items If you created UIToolbar in Interface Builder you can change it's tint there and that applies for..

Detect iPhone Browser

http://stackoverflow.com/questions/3827466/detect-iphone-browser

user_agent 'iPhone' FALSE if isIphone header 'Location http www.yourwebsite.com phone' exit ...THE REST OF YOUR CODE HERE and in javascript you can write var agent navigator.userAgent var isIphone agent.indexOf 'iPhone' 1 agent.indexOf 'iPod'..

Compare two NSDates for same date/time [duplicate]

http://stackoverflow.com/questions/5629154/compare-two-nsdates-for-same-date-time

NSDate dateToCompare NSDate date1 self dateWithNoTime NSDate date2 dateToCompare dateWithNoTime return date1 date2 HERE IS WHERE THINGS SEEM TO FAIL iphone objective c nsdate nscalendar nsdatecomponents share improve this question You're.. dateToCompare NSDate date1 self dateWithNoTime NSDate date2 dateToCompare dateWithNoTime return date1 date2 HERE IS WHERE THINGS SEEM TO FAIL iphone objective c nsdate nscalendar nsdatecomponents share improve this question You're comparing..

integrate facebook with like button in android and iphone

http://stackoverflow.com/questions/5935034/integrate-facebook-with-like-button-in-android-and-iphone

shareIntent.setType text plain shareIntent.putExtra android.content.Intent.EXTRA_SUBJECT YOUR SUBJECT HERE shareIntent.putExtra android.content.Intent.EXTRA_TEXT YOUR TEXT HERE startActivity Intent.createChooser shareIntent YOUR..

MKPinannotation detail disclosure button - present new view

http://stackoverflow.com/questions/6195774/mkpinannotation-detail-disclosure-button-present-new-view

region MKCoordinateSpan span span.latitudeDelta 0.2 span.longitudeDelta 0.2 MOST CODE WILL BE INSERTED HERE INSTRUCTIONS CCLocationCoordinate2D companyCity mapView.userLocation.coordinate companyCity.latitude latitude here companyCity.longitutde..

Custom Font in ios not working

http://stackoverflow.com/questions/6631292/custom-font-in-ios-not-working

57.869 myApp 5159 207 HelveticaNeue UltraLightItalic 2011 07 08 17 32 57.869 myApp 5159 207 HelveticaNeue UltraLight HERE IT IS 2011 07 08 17 32 57.869 myApp 5159 207 HelveticaNeue BoldItalic 2011 07 08 17 32 57.870 myApp 5159 207 HelveticaNeue..

iPhone: How to load a View using a nib file created with Interface Builder

http://stackoverflow.com/questions/863321/iphone-how-to-load-a-view-using-a-nib-file-created-with-interface-builder

object a as UIView subclass defining some IBOutlets. Create using Interface Builder the Question1View.xib HERE IS WHERE MY PROBLEM PROBABLY ARE . I set the both the ViewController and the View to be of class Question1View. I link the.. object a as UIView subclass defining some IBOutlets. Create using Interface Builder the Question1View.xib HERE IS WHERE MY PROBLEM PROBABLY ARE . I set the both the ViewController and the View to be of class Question1View. I link the outlets..

Changing the background color of a UIAlertView?

http://stackoverflow.com/questions/883208/changing-the-background-color-of-a-uialertview

And you can change this image UIAlertView theAlert UIAlertView alloc initWithTitle @ Atention message @ YOUR MESSAGE HERE nil delegate nil cancelButtonTitle @ OK otherButtonTitles nil autorelease theAlert show UILabel theTitle theAlert valueForKey..