Wednesday 28 November 2012

In App Purchases in iOS



Adding In-App Purchase to your iOS and Mac Applications:

http://developer.apple.com/library/ios/#technotes/tn2259/_index.html



In App Purchases: A Full Walkthrough

http://troybrant.net/blog/2010/01/in-app-purchases-a-full-walkthrough/

 

Introduction to In-App Purchases (iOS 5):

http://www.raywenderlich.com/2797/introduction-to-in-app-purchases

for iOS 6:

http://www.raywenderlich.com/21081/introduction-to-in-app-purchases-in-ios-6-tutorial

 

 

 

 

Sunday 25 November 2012

AddressBook iOS 6 issues


Problem:



I am updating an app for iOS 6 Address Book authorization and have hit a problem in testing. The simulator always returns that authorization is granted. This means I do not see the dialog popup requesting permission and can therefore not test that code path. Ok, use a device instead... The problem there is the OS appears to remember my answer so only asks once. Deleting the app does not help. On reinstalling it has retained the permission setting from before, so again no popup.

Solution:

From the device, Settings->General->Reset->Reset Location & Privacy.


http://stackoverflow.com/questions/12602984/abaddressbookgetauthorizationstatus-in-simulator-always-returns-kabauthorization



Problem:

dyld: lazy symbol binding failed: Symbol not found: _ABAddressBookCreateWithOptions
or
dyld: Symbol not found: _ABAddressBookCreateWithOptions


Solution:

this code was failing for me at ABAddressBookGetAuthorizationStatus() in iOS5, but as per yunas' answer below, I checked if (ABAddressBookRequestAccessWithCompletion != nil) before going into the ABAddressBookGetAuthorizationStatus() code, and it was true/false for iOS6/5. I'm sure there'll be a more elegant way to cope with the two versions of iOS, but it's done the trick for now.


 if (ABAddressBookRequestAccessWithCompletion != NULL)   // we're on iOS 6
    {
    ....................  


    }
   
    else    // we're on iOS 5
    {
        return YES;
    }
 



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


Thursday 22 November 2012

Create Indexed UITableView (Section)

http://www.iphonedevcentral.com/indexed-uitableview-tutorial/


Tackling that handy index on the right side of table views is really not that complicated. In fact, it only requires that you implement two methods. In this tutorial, I’m going to take you step-by-step on how to wire it all together.




Indexed Table 2

Wednesday 21 November 2012

UICollectionView In iOS 6


http://www.raywenderlich.com/22324/beginning-uicollectionview-in-ios-6-part-12



When Apple first launched the iPad in 2010, you might have been particularly impressed by the Photos app bundled with the device. It had a unique and stylish way of displaying photos via a multitude of layouts. You could view your photos in a nice grid view:

Or you could view your photo albums at the top level as stacks:

You could even transition between the two layouts with a cool pinch gesture. “Wow, I want that in my app!”, you may have thought.
Well, implementing a grid view and other alternative layouts like this was possible to get working on your own, but also quite tricky! It required a lot of code and was difficult to get working exactly right. Couldn’t there be an easier way?
Good news – now there is in iOS 6! Apple has introduced a new class called UICollectionView that makes adding your own custom layouts and layout transitions (like those in the Photos app) incredibly simple to build.
You’re by no means limited to stacks and grids, because UICollectionView is extremely customizable. You can use it to make circle layouts, cover-flow style layouts, Pulse news style layouts – almost anything you can dream up!
The bottom line is you have an exremely powerful new way to present ordered data to users, and you should start learning about it! It’s just as important (and helpful) of a class as UITableView is. The good news is if you’re familiar with UITableView, you’ll have no problem picking it up – using it is very similar to the table view data source and delegate pattern.
In this tutorial, you’ll get hands-on experience with UICollectionView by creating your own grid-based photo browsing app. By the time you are done this tutorial, you will know the basics of using UICollectionView and will be ready to start using this amazing technology in your apps!

Anatomy of a UICollectionViewController

Let’s go right to an example of one of these babies in action. The UICollectionViewController family contains several key components, as you can see below:

Take a look at these components one-by-one:
  1. UICollectionView – the main view in which the content is displayed, similar to a UITableView. Note that it doesn’t necessarily have to take up the entire space inside the view controller – in the screenshot above, there’s some space above the collection view where the user can search for a term.
  2. UICollectionViewCell – similartoaUITableViewCellinUITableView. Thesecells make up the content of the view and are added as subviews to the UICollectionView. Cells can either be created programmatically, inside Interface Builder, or via a combination of the two methods.
  3. Supplementary Views – if you have extra information you need to display that shouldn’t be in the cells but still somewhere within the UICollectionView, you should use supplementary views. These are commonly used for headers or footers of sections.
  4. Decoration View – if you want to add some extra views to enhance the visual appearance of the UICollectionView (but don’t really contain useful data), you should use decoration views. Background images or other visual embellishments are good examples of decoration views.
  5. In addition to the above visual components, UICollectionView also has non-visual components that help with laying out content:
  6. UICollectionViewLayout – UICollectionView does not know anything about how to set up cells on screen. Instead, its UICollectionViewLayout class handles this task. It uses a set of delegate methods to position every single cell in the UICollectionView. Layouts can be swapped out during runtime and the UICollectionView can even automatically animate switching from one layout to another!
  7. UICollectionViewFlowLayout – You can subclass UICollectionViewLayout to create your own custom layouts (as you’ll learn about in the next tutorial), but Apple has graciously provided developers with a basic “flow-based” layout called UICollectionViewLayout. It lays elements out one after another based on their size, quite like a grid view. You can use this layout class out of the box, or subclass it to get some interesting behavior and visual effects.
You will learn more about these elements in-depth throughout this tutorial and the next. But for now, it’s time for you to get your hands into the mix with a project!

Automated Testing With Xcode


http://www.raywenderlich.com/22324/beginning-uicollectionview-in-ios-6-part-12

Passbook in iOS 6


http://www.raywenderlich.com/20734/beginning-passbook-part-1

http://www.raywenderlich.com/20734/beginning-passbook-part-1


The passes implementation in iOS 6 is the hottest technology coming out from Apple right now, and it’s groundbreaking for more reasons than one might imagine.
Passes are the result of some awesome fusion. Four separate technologies all combine together to deliver a completely new experience to iPhone users:
  1. The new iOS framework PassKit
  2. The new Passbook app bundled with iOS
  3. Apple’s push notification service (this time delivery is guaranteed)
  4. Your own server code!
Passes are very different from any other Apple technology you’ve used before. What makes them unique is that passes are a concept wrapped around a file format. It’s up to you to create a pass file, deliver and present it to the user in any way you like. And the choice of technology and programming language to do that is also up to you!
It hardly needs to be said that with this setup, you have much more control over how you implement things than you normally do with Apple technology.
Since Apple does not handle the mechanisms behind passes, you need to employ a bunch of different technologies to make them work. In this tutorial, you’ll use Objective-C and iOS; use JSON; send multi-part emails with attachments; use OpenSSL to digitally sign files; and more.
The tutorial is divided into two parts:
  1. First, you’ll learn how to create a pass by hand. You’ll start with an empty file and finish with a completely styled and digitally-signed pass.
  2. In the second part, you’ll develop a small iOS app in order to preview passes in the iPhone Simulator or on your device. You’ll also learn about different kinds of passes, thus becoming a Pass Pro.
The trip through this chapter will be wild, but also very rewarding – by the end of it, you’ll have mastered the very latest in Apple technology!

Auto Layout in iOS 6



http://www.raywenderlich.com/20881/beginning-auto-layout-part-1-of-2

http://www.raywenderlich.com/20897/beginning-auto-layout-part-2-of-2


Tuesday 20 November 2012

UIDeviceID (uniqueIdentifier) DEPRECATED Ulternative

In iOS 5 – method UIDevice currentDevice uniqueIdentifier as __OSX_AVAILABLE_BUT_DEPRECATED.

So i have found another solution

Try https://github.com/hiren443/UIDevice-with-UniqueIdentifier-for-iOS-5. It provides two methods, one which is a global UDID that uses the MAC address of the device, and hashes it. The other is an app specific id which uses the MAC address + bundle identifier of the app to generate a hashed UID for the app. I have tried both and they work like a charm. Try-
[[UIDevice currentDevice] uniqueGlobalDeviceIdentifier] //for the global identifier
OR
[[UIDevice currentDevice] uniqueDeviceIdentifier]

AFNetworking alternative fro ASIHTTPRequest for iOS 5 or above



https://github.com/AFNetworking/AFNetworking



http://stackoverflow.com/questions/7623275/afnetworking-post-request


 

Programmatically Request Access to Contacts in iOS 6


Reference: http://stackoverflow.com/questions/12570774/cant-access-contacts-sources-on-device-in-ios-6


+ (BOOL)contactsServicesEnabled
{
   
   
    if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusNotDetermined) {
        return YES;
    }
    else if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusAuthorized) {
        return YES;
    }
    else {
        return NO;
    }

}

Monday 19 November 2012

TSAlert View with TextField


Reference:  http://stackoverflow.com/questions/6735968/ios-uitextfield-in-uialertview



The only proper solution I found (ie coding from scratch from a UIView) is here: https://github.com/TomSwift/TSAlertView
This is all it takes:

- (IBAction) importTap
{
    TSAlertView* av = [[[TSAlertView alloc] init] autorelease];
    av.title = @"Enter URL";
    av.message = @"";

    [av addButtonWithTitle: @"Ok"];
    [av addButtonWithTitle: @"Cancel"];


    av.style = TSAlertViewStyleInput;
    av.buttonLayout = TSAlertViewButtonLayoutNormal;
    av.delegate = self;

    av.inputTextField.text = @"http://";

    [av show];
}

// after animation
- (void) alertView: (TSAlertView *) alertView 
didDismissWithButtonIndex: (NSInteger) buttonIndex
{
    // cancel
    if( buttonIndex == 1 )
        return;

    LOG( @"Got: %@", alertView.inputTextField.text );
}








enter image description here

Saturday 17 November 2012