Wednesday 20 February 2013

Use Compiler Flags to Enable and Disable ARC



ARC is supported in Xcode 4.2 and later OS X v10.6 and later (64-bit applications) and for iOS 4 and later. Weak references are not supported in OS X v10.6 and iOS 4. There is no ARC support in Xcode 4.1 and earlier.

Enable ARC -> -fobjc-arc
Disable ARC -> -fno-objc-arc

Project -> Build Phases -> Compiler Sources -> Set Compiler flag for particular file.

You enable ARC using a new -fobjc-arc compiler flag. You can also choose to use ARC on a per-file basis if it’s more convenient for you to use manual reference counting for some files.
 For projects that employ ARC as the default approach, you can disable ARC for a specific file using a new -fno-objc-arc compiler flag for that file.

Finding Your iPhone’s Unique Identifier (UDID)


What is the UDID?

Each iPhone or iPod Touch has a Unique Device Identifier (UDID), which is a sequence of 40 letters and numbers that is specific to your device. It’s like a serial number but much harder to guess. It will look something like this:2b6f0cc904d137be2e1730235f5664094b831186.

Why do we need the UDID?

Your iPhone can only install programs that are approved by Apple. Applications in the App Store have been approved by Apple for general distribution, but beta customers get to try the app before it’s in the store. We register your UDID with Apple so they can approve our application especially for your iPhone.

How do I get my UDID?

You can copy/paste your UDID from iTunes or email it directly from your device by using a free app from the App Store.

Email Using the Free App

Install and run Ad Hoc Helper. It will create an email with your UDID. Send it to nobody@example.com.

Copy/Paste from iTunes

  1. Launch iTunes and connect your iPhone.
  2. In the right pane, locate the information about your iPhone, including its name, capacity, software version, serial number, and phone number.Plugged-in-iphone
  3. Reveal the Identifier by clicking on Serial Number:.Clicked-serial-number
  4. Copy the Identifier to your clipboard by choosing Edit → Copy.Edit-copy
  5. Paste the Identifier into an email to nobody@example.com (You should be able to paste into your mail program or web browser by selecting Edit → Paste).

Tuesday 19 February 2013

Step-by-Step Guide to Publishing in the Apple App Store Using Windows

Step-by-Step Guide to Publishing in the Apple App Store Using a Mac



Requirements

To publish an app through the Apple App Store, you need to have an Apple Developer account and be a member of the iOS Developer Program. Your app also needs to meet Apple's App Store guidelines.

Files Needed for iOS Publishing:

  1. Identity - a unique ID for an app  that maps to the Bundle Identifier in the Apple Developer Center
  2. Distribution Certificate & Private Key (generated in Apple Developer Center)
  3. Distribution Provisioning Profile 
  4. Optional: Push Notification Certificate
  5. Icons
  6. Loading Screen


Setting up an Identity

  1. To Set up an Identity, go to the Apple Developer center iOS Provisioning Portal, and click the App IDs tab. 
  2. Click the New App ID button (top right), give the app id a name, and give it a Bundle Identifier (by convention, these take the form com.domain.appname, so for example, com.brightcove.myfirstapp)
    note: copy and save the Bundle Identifier you created because you will need to enter it into the App Cloud Studio when publishing your app
  3. Click Submit within the Apple developer center and it will create an App ID

Creating a Distribution Certificate & Private Key (on a Mac)

  1. Now you need to set up a distribution certificate. To do this, you will first need to generate a certificate request from your computer. On a Mac, you should do this by opening the Keychain Access application found in the Utilities.
  2. Go to Keychain Access - Choose Keychain Access -> Certificate Assistant ->Request a Certificate from a Certificate Authority.
  3. Enter your email address and name, and select Request is Saved to disk to save the file CertificateSigningRequest.certSigningRequest to your desktop.
  4. Now go back to iOS Provisioning Portal and click the Request Certificatebutton on the Distribution tab.
  5. Click Choose File to select the certificate request file on your desktop, and then click Submit. You will see your certificate appear with the status Issued.
  6. Refresh the page, and additional information will appear: the Expiration Date, and Download and Revoke under Actions.
  7. Click the Download button, and save the certificate file.
  8. After the file downloads, locate the distribution_identity.cer file in your downloads directory, and double-click it to import it to Keychain Access.
  9. Now return to Keychain Access and locate the certificate with the name beginning iPhone Distribution.
  10. Expand it to reveal the attached private key, and select both the certificate and private key
    note: it is very important to select both files
  11. With both items selected, right click to export them to a .p12 file that you can save on your desktop or elsewhere. You will need to upload this file to App Cloud during the app submission process.
  12. As you save the file, you will have the option of adding a password to protect the file - if you do, just be sure to remember what the password is. You will also be asked to enter your machine password, as you are for many Keychain Access actions.

Creating a Distribution Provisioning Profile

  1. In the Apple Developer Center, go to the Provisioning tab > Distribution and select new profile
  2. Leave the Distribution Method as App Store
  3. Give it a profile name
  4. Select the App ID that you created for this app and click submit
  5. Wait for the provisioning profile to be created (refresh the page)
  6. Click to download the file to your machine. You will need to upload this file into the App Cloud Studio.

Setting Up Push Notifications

  1. If you are going to use Push Notifications in your app, you will now need to set up another SSL certificate for push notifications. Unlike the distribution certificate, this one is specific to the app, so you will work from  the app id you created.
  2. Go to Keychain Access - Choose Keychain Access -> Certificate Assistant -> Request a Certificate from a Certificate Authority.
  3. Enter your email address and name, and select Request is Saved to disk to save the file CertificateSigningRequestPush.certSigningRequest to your desktop.
  4. Now return the iOS Provisioning Portal in the Apple Developer Center, go to the App IDs section, find the ID you created earlier, and click Configure.
  5. In the new page that opens, check the box beside Enable for Apple Push Notification service. Now you will be able to click the Configurebuttons, and since you are going to submit this app, you will need a Production Push SSL Certificate.
  6. Click configure, and a dialog will open up with instructions
  7. Click Continue to go to the next screen
  8. Click the Choose File button and select the CertSigningRequestPush.certSigningRequest file you just created, click Generate
  9. After the certificate is generated, click Continue.
  10. Click Download to download the file to your computer and click the show in folder option to navigate to where the file is located
  11. Copy the file and save it to your Desktop or some other location
  12. Find the downloaded certificate file, and double-click it to import it into Keychain Access.
  13. In Keychain Access, again expand the certificate to reveal the private key, selectboth items, and right click to export them to the desktop as a .p12 file
  14. Now you will need to convert the .p12 file to a PEM file using OpenSSL. OpenSSL is included in the Mac OS
  15. To start OpenSSL open Terminal and type OpenSSL at the command prompt and press return to get an OpenSSL command prompt.
  16. Now type: pkcs12 -in <your p12 with full path> -out <the PEM filename> -nodes
    note: Where it says <your p12 with full path> you can drag and drop your .p12 file into Terminal to easily enter the full path of the file
    note: Where is says <the PEM filename> you can use a file name such as PushCert.pem
  17. The PEM file that is generated is what you will need to upload into the App Cloud Studio

Icons

An iOS app uses icons to represent the app in the Apple App Store and to launch the app on the device itself after it's installed. You can upload an image file and App Cloud will create these icons for you. All images should have a square aspect ratio (equal width and height) and be in PNG format. Image files may be not more than 1 Mb in size.

Loading Screen

When a user launches your app, the iOS device displays a fullscreen graphic. Upload an image file that the app can use for this purpose. For an iPhone app, this file must be 640x960 exactly. For an iPad app, provide two loading screen image files, one with portrait orientation (768x1024 pixels) and the other with landscape orientation (1024x768 pixels)
Remember that you can resize images using the App Cloud image transcoding service.
You can Follow this for more info

How to Create a Provisioning Profile for iPhone

1st click on this link and start start   http://www.wikihow.com/Create-a-Provisioning-Profile-for-iPhone

EditSteps

  1. 1
    Log in to the iOS Development Center athttps://developer.apple.com/devcenter/ios/index.action

    Invest with the Master

     UTI Mastershare Steady Returns, Long Term Capital gain. Know more!
    www.utimf.com/MasterShareTaxBenefit
  2. 2
    Enter the Developer Program Portal. Click on the "iOS Developer Program Portal" on the right side of the page, under "iOS Developer Program".
    • Note that if you are not a registered Apple iOS Developer, you will need to sign up for this program before proceeding so that you can run a simulation on your IOS device. Currently the development program is currently a $99 annual fee to join.
  3. 3
    Click on Provisioning on the left side of the page. Once ou have logged into the iOS Provisioning portal, you can do this.
  4. 4
    Click on the "New Profile" button.
  5. 5
    Enter a profile name. Select the certificates and devices you would like to associate with this profile, then choose an app ID.
  6. 6
    Click submit. This will generate your profile.

Downloading a Development Provisioning Profile

  1. 1
    Log into the iOS Provisioning Portal. Once logged in, click Provisioning on the left-hand side.
  2. 2
    Select the appropriate tab. Click either the Development or the Distribution tab to show your profiles.
  3. 3
    Download the profile. Locate the desired Provisioning Profile, and in the Actions column, click the Download button.

Saturday 16 February 2013

InterView Question's


Hello All , find below some iPhone interview questions . I hope this will help you to face the technical interview . I will be modifying this post with some more questions and answers in a couple of days , so keep checking this post for more .

1. What is @interface?
- It’s a keyword used to declare the Class.


2. What is @implementation?
- It’s a keyword used to define the Class.


3. Garbage collector in iPhone?
- iOS 5.0 has got the ARC ( Automated reference counting ).  Objective C does not have a garbage collector rather it uses the reference counting algorithm to manage the memory. This was the developers task until Apple launched iOS 5.0. Again if you are targeting iOS 4.0 or earlier , ARC is no more a choice for you .

4. What is delegate?
- Delegate is an object that handles the events happening on an object. To do that delegate has to follow a protocol specifying the task it is going to handle .


5. What is @synthesize?
- We use @synthesize to generate getters and setters automatically from compiler. We declare properties and then generate getter and setter method by using @synthesize.


6. What are the features of iOS 5.0 ?
- https://developer.apple.com/technologies/ios5/


7. What is nonatomic ?
- nonatomic and atomic are related to multithreading environment .
 - If a property has an attribute as “nonatomic” that means multiple threads can modify that property concurrently.
- If the attribute is “atomic”, the threads would be given access atomically.
-  So “Atomic” is thread safe while “nonatomic” is thread unsafe.
- Atomic drastically hampers the performance so until and unless not needed you should never go for atomic attribute. ‘nonatomic ’ will do in most of the cases.


8. What are the delegate methods of MKMapView ?
- Check the MKMapViewDelegate in the Documentation. If you don’t have Xcode with you then search on Google.


9. What are the important delegate methods of NSXML parser?

-DidStartElement
-FoundCharecters
-DidEndElement
-FoundError



10. What is @dynamic and any place where it is used ?
- It tells compiler that getter and setter are not implemented by the class but by some other class .
- May be super class or child class .

Example – Core Data
-       The Managed object classes have properties defined by using @dynamic.


11. What is @property?
- It is a keyword used to declare a property.

12. What is data source?
- The datasource is an object that implements the required datasource protocol that is needed to create a complex control.
Ex UITableView is a view that needs a datasource object to which will help building the table. Often it’s the controller that is displaying the table view. The protocol that dataSource object ( mostly controller it self) has to implement is “UITableViewDataSource” .

13. What is model view controller?
- MVC is a Design pattern .
Model stands for the database  object which will manage all the database transaction .
- View stands for the UI i.e. the UI visible to the user. User will be interacting with the view.
- Controller is an object who handles the view events and also render the database changes to the UI. In short , it bridges the interaction between Modal and View.



14. what is @ protocol?
- @protocol is a keyword used to define a protocol. A protocol is a set of method declarations defining specific purpose. It only lists out the methods prototype , the actual implantation would be provided by the class that implements /  follows the protocol.


15. what is id?
- id is a generic reference type. The variable declared using id data-type can hold any object. Most of the methods that returns an object has ‘id’ as return type. Ex – init.

16. Explain memory management?
- Most of the object oriented languages have the Garbage Collector .  All the objects are allocated on the heap memory. The Garbage Collector is a thread that runs periodically to check all the objects, which are no more being referenced from the program. Garbage collector then de-allocates all these unreferenced objects on the Heap. In this environment programmer does not need to worry about de-allocating the objects explicitly.

In Objective – C we don’t have garbage collector. ( Note: Its available from iOS 5.0 only). So in this environment we have to explicitly take care of allocation and deallocation of all the objects in our program.  And to manage this Objective C uses ‘reference counting’ algorithm as the memory management algorithm. 

Reference Counting: In this algorithm every object keeps track of it owners ( I,e reference variables from the program ) . No of owners is represented by the property retainCount declared in NSObject. If this retainCount goes to ‘0’ the object gets deallocated automatically.  We never call dealloc method on any object explicitly.


17. what is retain and release?
- retain and release are two method defined in NSObject . - -
- These methods are related to Memory Mangement .
- retain method when called increases the retainCount by 1.
- release method when called decreases the retainCount by 1


18. what is dealloc?
- dealloc method is called on an object to actually deallocate the memory for that object. ( We should never call dealloc directly )
- In reference counting environment when retainCount of an object reaches to ‘0’, the dealloc method is called on that object automatically to delete the memory space of the object .
- If the object is having some reference type variable holding other objects, then we should call release method on every variable in dealloc.
- If you override then [super dealloc] should be the last line in this method.


19. What is Autorelease pool?
-  Autorelease pool is like a container that holds the autoreleased objects .
- This pool is drained with every run-loop of the Application
- When the pool gets drained, autorelease pool sends a release message to all the objects it was holding.



20. What is Foundation Framework? Can you explain some classes from that?
- Foundation is one of the important frameworks in COCOA Touch.
- It contains the classes like  NSArray , NSString , NSObject etc .


21. What is the difference between NSArray and NSMutableArray?

* NSArray
-        is a static array
-       Once created you can not modify the array
-       Ex you can not add or remove the object in NSArray.

* NSMutableArray
-       is a dynamic array
-       You can add or remove the object dynamically.


22. Write a delegate method of the table view?
 - (void)tableView:( UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath


23. What are the delegate methods of NSURLConection?
- didReceiveResponse:
- didReceiveData:
- didFinishLoadingData:
- didFailWithError:


24. What is cocoa ?
- COCOA is a collection of frameworks used to write Applications for MAC OS X.


25. Singleton classes
- A singleton class is such a class from which no more that one instance can be created. So there will always be single instance created throughout the program.
Ex UIApplication.