Monday, January 28, 2013

Few tips on ARC Compatibility - enabling/disabling your project ARC

Most of you guyz already know what really  ARC means, but for rest of you which are unknown about it, ARC means Automatic Reference Counting, is a feature of the new LLVM 3.0 compiler and it completely replaces the manual memory management that means we do not have to worry about memory releases of the objects we create. ARC has removed the use of retain, release, autorelease keywords and it acts like a garbage collector. ARC will take care of all the memory issues, and we developer do not have to worry about it any more.


PROBLEM :
However, since ARC is a new feature in iOS development , we may find compiling errors regarding memory keywords  while we want to mix up old projects with new ARC enabled ones, or  error occurs when we want to use ARC disabled  third party libraries to our ARC enabled project. Just like in pic:


Friday, January 25, 2013

Sending e-mail in background from iOS apps using SMTP gmail account

The iOS SDK has made it really easy to send email using the built-in APIs. With a few line of codes, you can launch the same email interface as the stock Mail app that lets you compose an email. You can pop up mail composer form , write message and can send plain mail or file attached mail using MFMailComposeViewController class. For more info : Sending e-mail from your iOS App

But, in this section what i am going to explain is about sending emails without showing the mail composer sheet ie. sending emails in background. For this feature, we can not use iOS native MFMailComposer class because it does not allow us to send emails in background instead it pop ups the mail composer view from where user have to tap "send" button , so for this section i am going to use  SKPSMTPMessage Library to send emails in background, however email account has to be hardcoded on this method.

Limitations :
1. sender/receiver email address has to be hardcoded or you have to grab it using some pop up form in your app where user inputs sender/receiver email address. In addition, sender account credentials has to be also hardcoded since there is no way we can grab it from device settings.

Method :
1. Import CFNetwork.framework to your project.
2. Include     #import "SKPSMTPMessage.h"
                    #import "NSData+Base64Additions.h" // for Base64 encoding
3. Include <SKPSMTPMessageDelegate> to your ViewController
4.  Download SKPSMTPMessage library from  
                                             https://github.com/jetseven/skpsmtpmessage
5. Drag and Drop "SMTPLibrary" folder you have downloaded to your project.

  Before proceeding, let you know that i am using sender/receiver email address and sender password hardcoded in the code for this example.But, you may grab this credentials from user, allowing them to input in some sort of forms(using UIViews).

Friday, January 18, 2013

Integration of File Sharing from your App to iTunes

Hey guyz, in this section i will be explaining about how we can share app's files which are stored in its document directory  via itunes, say, accessing app's document directory. For example, lets say some app named "testApp" stores bunch of files in its documents folder which are downloaded from web, now we may want to see those files in our desktop. So for file sharing, iOS 4 & later have a great new feature called File Sharing that provides a convenient way for users to transfer files between their computer and your app.

Its really a simple step and it goes like this.......
- To enable File Sharing in your app, you simply set the boolean flag UIFileSharingEnabled in your info.plist. Or , some of you may find Application supports iTunes file sharing flag in your info.plist. Just set flag to YES.


After that, iTunes will display anything you save to the Documents directory in your app to the user, when they go to the “Apps” page in iTunes like this :
Note : One thing, you must keep in your mind is that only the files that are stored in your app's documents directory can be seen and shared!!! For storing files in documents directory, please have a look at :  Handling NSDocumentDirectory of iOS App

That's all from Xcode side, Now for more details on  File sharing features : http://support.apple.com/kb/HT4094#

Thursday, January 17, 2013

Checking Internet Connection in iOS Apps

In this section, i will be describing about how we can check internet connectivity in iOS apps. For this kind of task, Apple has provided a very helpful sample reachability class . So, we will be using that class to make it working on our apps. First , grab the reachability sample code from: http://developer.apple.com/library/ios/#samplecode/Reachability/Introduction/Intro.html

Now, you don't have to ho through all the codes in sample app, just follow these few steps to check internet connection in our app :

  1. Add the SystemConfiguration.framework to your project.
  2. Add the files Reachability.h and Reachability.m only from the Reachability sample code you just downloaded to your project.
  3. Add the following code in the implementation file where you need to test the Internet connection.    

Thursday, December 20, 2012

Having problem on creating .ipa file from Xcode's "Product -> Archive" or "Build & Archive" method ?

                 Creating an IPA is done in a simple way from your Xcode : Product -> Archive (previously Build & Archive). After the Archive operation completes, go to the Organizer, select your archive, select Share and in the "Select the content and options for sharing:" pane set Contents to "iOS App Store Package (.ipa) and Identity to iPhone Distribution (which should match your ad hoc/app store provisioning profile for the project).
It's a simple stuff to do but BANggggg... You might be in trouble if you have been using some other static library, third party library, other xcode project files in your project. You might have following issue that disables your .ipa file selection :
 “No Packager exists for the type of archive and This kind of archive cannot be signed."

Wednesday, December 19, 2012

Opening iOS Apps from Browser or any other source using URL Scheme in iOS Devices

In this section, i will be describing about how to open up an app in iOS device either from a Browser or from any other application present in iOS devices.

First thing you need to do is to register a URL scheme  in to device which is done in your app's info.plist file. URL Scheme will be your key to open up your app from browser or any other app. Here are the step by step procedure :
First open up your info.plist
Step 1. Right-Click and “Add Row”
screen-capture.png

Wednesday, October 3, 2012

"Pull Down To Refresh" integration for updating data in UITableViews

Hello Guyz , in this section we will be talking about "Pull Down To Refresh" integration for updating your data in UITableView. This kind of effect can be seen in  facebook app, where we  pull down the view and it refreshes/updates the facebook feeds. In the similar way, in this section i will write a bunch of codes that basically do is: when we pull down the UITableView, it will updates its datasource and reload the table section. Here, is the example screen that will help you to understand about this effect more wisely.
download and add this dropdown image to be used in project named updateArrow.png