Sunday 29 September 2013

Icon and Image Sizes iOS 7

Description
Size for iPhone 5 and iPod touch (high resolution)
Size for iPhone and iPod touch (high resolution)
Size for iPad (high resolution)
Size for iPad 2 and iPad mini (standard resolution)
App icon (required for all apps)
120 x 120
120 x 120
152 x 152
76 x 76
App icon for the App Store (required for all apps)
1024 x 1024
1024 x 1024
1024 x 1024
1024 x 1024
Launch image (required for all apps)
640 x 1136
640 x 960
1536 x 2048 (portrait)
2048 x 1536 (landscape)
768 x 1024 (portrait)
1024 x 768 (landscape)
Spotlight search results icon (recommended)
80 x 80
80 x 80
80 x 80
40 x 40
Settings icon (recommended)
58 x 58
58 x 58
58 x 58
29 x 29
Toolbar and navigation bar icon (optional)
About 44 x 44
About 44 x 44
About 44 x 44
About 22 x 22
Tab bar icon (optional)
About 50 x 50 (maximum: 96 x 64)
About 50 x 50 (maximum: 96 x 64)
About 50 x 50 (maximum: 96 x 64)
About 25 x 25 (maximum: 48 x 32)
Default Newsstand cover icon for the App Store (required for Newsstand apps)
At least 512 pixels on the longest edge
At least 512 pixels on the longest edge
At least 512 pixels on the longest edge
At least 256 pixels on the longest edge
Web clip icon (recommended for web apps and websites)
120 x 120
120 x 120
152 x 152
76 x 76


Designing app for iOS 7

Deference, clarity and depth are the main themes for iOS 7 development. Focus on core functionalities and content and keep the design simple.

Provide clarity:
  1. Use plenty of negative space, negative space make important content more noticeable. 
  2. Let color simplify the UI.
  3. Ensure legibility by using the system fonts. 
  4. Embrace borderless buttons.   

Content is at the heart of iOS 7: 
  1. Take advantage of the whole screen, let content extend to the edges.
  2. Reconsider visual indicators of physicality and realism, avoid heavy UI elements, keep it simple, focus on content and let the UI have the supporting role. 
  3. Let translucent UI elements hint at the content behind them.



Monday 2 September 2013

REQUEST_DENIED when using the Google Places API


<PlaceSearchResponse>
  <status>REQUEST_DENIED</status>
</PlaceSearchResponse>

I had this problem for a while, and could not find any solution for it on the web. But I did manage to sort it out, if you need a quick fix do the following:

In google api console when creating your key, I chose the server and left the field blank so it allows any IP. Now my api key works perfectly fine.

Key for server apps (with IP locking)
API key:
your api key
IPs:
Any IP allowed
Activated on:  date
Activated by:  you

I did the same for my ios key now it works on all of my ios apps.

Monday 19 August 2013

What are the popular tags on instagram?

Most popular tags on instagram:


#love #TagsForLikes #TFLers #tweegram #photooftheday #20likes #amazing #followme 
#follow4follow #like4like #look #instalike #igers #picoftheday #food #instadaily
 #instafollow #like #girl #iphoneonly #instagood #bestoftheday #instacool
 #instago #all_shots #follow #webstagram #colorful #style #swag
 
 
 



Wednesday 7 August 2013

How to get user's current location in your app (iOS programming)

To get current location in iOS:

---> #import <coreLocation/coreLocation.h>
1- Create an instance of CLLocationManager
2- Assign a delegate to the CLLocationManager object
3- Set desiredAccuracy & distanceFilter
4- Call startUpdatingLocation
5- locationManager reports the event to this method ---> locationManager:didUpdateLocations (iOS 6 & Later)


Sample Code:


-----> .h File
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>

@interface infinityViewController : UIViewController <CLLocationManagerDelegate>{

    CLLocationManager *locationManager;
}
@end

----> .m File

#import "infinityViewController.h"


@interface infinityViewController ()


@end



@implementation infinityViewController


- (void)viewDidLoad
{
    [super viewDidLoad];
   
    [self getCurrentLocation];
   
   
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)getCurrentLocation

{
   
    if (locationManager == nil  )
       
        locationManager = [[CLLocationManager alloc] init];
   
   
   
    locationManager.delegate = self;
   
    locationManager.desiredAccuracy = kCLLocationAccuracyKilometer;

   
    locationManager.distanceFilter = 400;
   
   
   
    [locationManager startUpdatingLocation];
   
}


- (void)locationManager:(CLLocationManager *)manager

     didUpdateLocations:(NSArray *)locations {
       
    CLLocation* currentLocation = [locations lastObject];
   
    NSDate* eventDate = currentLocation.timestamp;
   
    NSTimeInterval howRecent = [eventDate timeIntervalSinceNow];
   
    if (abs(howRecent) < 20.0) {
       
       
        NSLog(@"Latitude Value: %+.6f\n",currentLocation.coordinate.latitude);
                   
        NSLog(@"Longitude Value %+.6f\n",currentLocation.coordinate.longitude);
       
    }
   
}

@end

written by: infinitywebseo 

Tuesday 2 July 2013

Write Objective C code for absolute beginner (Quick Guide)

Objective C is basically object oriented C, its an extend C programming language. So, it has the basic syntax as C, are the primitive types, structures, functions, control flows (if, else, for, ...), pointers, and libraries.

What objective C adds to C ---> Defining new class, instance methods, methods invocations, automatic synthesizing of accessor methods, static and dynamic typing, blocks plus protocols and categories.

Lets start with classes and objects, a class encapsulates the data and defines actions to operate on that data and object is run time instance of the class.

Class extensions in objective C:
  • .h is the header file.
  • .m is the implementation file.
  • .mm is the implementation file if you are using C++ in your code as well.
 .h file:

@interface className : parentClassName

{
    // Member variables

}

 //method declarations

@end





.m file: 

// #import directive is like #include directive in C the difference is that #import directive makes sure // that the same header file never included more than once.

#import className.h

@implementation className
{
   

}

Objective C allows both static and dynamic typing:

className *object1;  // Static typing
id       object2;  // Dynamic typing
NSString *myName;  // static typing
 
 
Methods in objective C ----> Instance Methods and Class Methods
For instance method you need to create an instance of the class first then use the method. But Class Method dose not requires an instance of the class to be receiver of the message.

Instance method declaration is preceded by a minus sign (-). For Class Methods, its a plus sign (+).
 
written by: infinitywebseo 

Monday 1 July 2013

What is autoreleasepool?

@autoreleasepool {

 return UIApplicationMain(argc, argv, nil, NSStringFromClass([yourAppNameAppDelegate class]));

}

Basically autoreleasepool supports automatic reference counting, which provides automatic object-life time management for your iOS application.

In simple words it just makes sure that objects are around as long as they are needed in your app and not longer.

written by: infinitywebseo 

Wednesday 26 June 2013

How to create iCloud entitlements file manually?

Creating entitlements file manually is very simple, open the text editor and just copy and paste the following lines of code: (save it as <yourappname>.entitlements)

<?xml version="1.0" encoding="UTF-8">
<!DOCTYPE plist PUBIC "-//Apple//DTD PLIST" 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>apple.developer.ubiquity-container-identifiers</key>

<array>
<string>$(TeamIdentifierPrefix).com.yourdomain.icloudapp</string>
</array>

<key>com.apple.developer.ubiquity-kvstore-identifier</key>
<string>$($(TeamIdentifierPrefix).com.yourdomain.icloudapp)</string>

</dict>
</plist>

After saving you file simply drag and drop it to your app on xcode.

written by: infinitywebseo 

Monday 24 June 2013

UIDocument does not allow you to write strings directly to disk

If you are using UIDocument in your app, always remember that UIDocument doesn't allow you to write strings directly to disk.

You need to package the string value in NSData then you can write it to disk. You can do it using the contentsForType:error method.

Below is a sample code, first check that the string is not NULL :

- (id)contentsForType:(NSString *)typeName error:(NSError **) myError{
    if (!self.stringDocument)
        self.stringDocument = @"";

    NSData *nsDataDocument = [self.stringDocument
                           dataUsingEncoding:NSUTF8StringEncoding];
    return nsDataDocument;
}

written by: infinitywebseo 

Wednesday 19 June 2013

How to Check iCloud is available in your app?

After enabling icloud on your app, just copy and paste the highlighted lines of code to your appdelegate.m to check that icloud is available for your app:

- (void)initializeiCloudAccess {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        if ([[NSFileManager defaultManager]
             URLForUbiquityContainerIdentifier:nil] != nil)
            NSLog(@"iCloud is available\n");
        else
            NSLog(@"iCloud is not available.\n");
    });
}


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
   
    [self initializeiCloudAccess];

    return YES;
}

The executable was signed with invalid entitlements. (0xE8008016)


Summary: if you have this error --> Try creating your new provisional profile through xcode > organiser it may solve the problem. (Don't create it trough your developer account on-line)

I had this error when I tried to run an app that uses icloud on an ios device. For icloud application you must create an app id  and new provisional profile.

What I did was that I create my new provisional trough my apple developer account website. Even thought I refreshed my provisional profile on xcode > organiser, I couldn't get rid of the error,  never mind few hours of searching on the web trying to find out the answer which was unsuccessful.


At the end, I just deleted my app id, and provisional profile. Then I create  a new app id, and this time I create my provisional profile through xcode > organiser, run my app again and it just worked.

written by: infinitywebseo 

Wednesday 12 June 2013

iOS 7 --> Things that you need to change about your app

 
All the contents on this blog are derived from apple developer website, its just a quick short-list for my own personal use.  I hope you find it useful.


Things I must do:
  • Update app icon to 120 x 120 (iOS 7 - Higher Resolution).
  • Update the launch image to include the status bar area.
  • Support Retina display.


Things I should do:  
Prepare for borderless buttons by moving away from supplying button background images and by reassessing your layout.

Use translucent UI Element & Auto-layout.

View controllers should use full screen layout. Don't use "wantsFullScreenLayout", its deprecated in iOS 7. Instead use the following properties:
  • edgeForExtendedLayout
  • extendedLayoutIncludeOpaqueBars
  • automaticalAdjustScrollViewInsets

For custom animated transitions between views click on --> UIViewControllerInteractiveTransitioning Protocol Reference


Using tint color: In iOS 7 tint is a property of UIView. Specify a tint color for entire app using following line: window.tintColor = [UIColor purpleColor]; By default tint color is nil which means that it uses the parent tint color. 
Remember, its best to change tint color when the app is off screen.


Bars and Bar Buttons barPosition in iOS 7 is a property for identifying bar position. The UIBarPositionTopAttached -----> a bar is at the top of the screen and its background extends upward into the status bar area. 
UIBarPositionTop ------> a bar is at the top of its local context—for example, at the top of a popover—and that it doesn’t provide a background for the status bar. 


Status Bar iOS 7
In iOS 7 You can control the style of the status bar from an individual view controller and change it while the app runs. In order to do it, add the UIViewControllerBasedStatusAppearance key to an app's Info.plist file and give it the value YES.


Navigation Bar iOS 7
Bar Style: by default the translucent property is YES.
Appearance: A one-pixel hairline appears a the button edge.  
Tinting: Use tintColor to tint bar button items.
             Use barTintColor to tint the bar background.


Collection View iOS 7
Collection view supports animated transitions between layouts. Click to read the documentation ------> UICollectionViewTransitionLayout Class Reference

Image View iOS 7
UI Image contains tintColor property and when image uses UIImageRenderingModeAlwaysTemplate mode, tintColor is applied to the image.

Map View iOS 7
In iOS 7 there is a new class called MKOverlayRenderer which you can use to create overlay on the top of map view.


Page View Controller iOS 7
To specify orientation use the following methods:
  • pageViewControllerPreferredInterfaceOrientationForPresentation
  • pageViewControllerSupportedInterfaceOrientations 
Scrol View in iOS 7  
automaticallyAdjustsScrollViewInsets ----> to manage scroll view insets.

written by: infinitywebseo 

 

 


Debt Collection

Debt Collectors

iOS 7 Beta a Quick Overview

iOS 7 Beta has so many bugs but the idea is great, its basically amazing. Can't wait for the final version.




written by: infinitywebseo 

Friday 17 May 2013

Multi-threading

Grand Central Dispatch (GCD) is a C API.  The basic idea is that you have queues of operations, which are specified using blocks. The blocks in the queue run in another thread except main thread.

There are two types of queues.  Serial Queues and Concurrent Queues
In serial queues blocks are executed in order. (one by one)

When do we use Multi-threading:

Accessing the network
Big calculation, hugs loines of code


Creating and releasing queues:
dispatch_queue_t dishpatch_queue_create(const char *label, NULL); // Null means serial queue

Putting blocks in the queue:
typedef void (^dispatch_block_t)(void);
void dispatch_async(dispatch_queue_t queue, dispatch_block_t block); //it puts the block in the queue then returns to main thread immediately

void dispatch_sync(dispatch_queue_t queue, dispatch_block_t block);  // puts the block in the queue and waits until the block finally gets to run to compelition and get backs to current thread

Getting the current or main queue
dispatch_queue_t dispatch_get_current_queue();
dispatch_queue_t dispatch_get_main_queue();


written by: infinitywebseo 

Sunday 12 May 2013

How to add tweet button to iOS app?

iOS includes a framework that you can use to add twitter to your iOS application. Follow the link below to see the full documentation:


What can I do with the framework?

  1. Single Sign-On
  2. Distribution
  3. Instant Personalization


written by: infinitywebseo 

Wednesday 1 May 2013

UITabBarController (Multiple MVCs)


Its a very common controller, It allows user to navigate between different views selecting different tabs.

The tabBarController's view is any number of viewController, simply control drag from the tabBarController to each of the viewControllers that represent the tabs.

By control dragging you are setting up following property in UITabBarController:

@property (nonatomic, strong) NSArray *viewControllers;


Tabs have icon and title which easily can be set on xcode. You can also add a badge on tab icons by the following line of code:

- (void) somethingHappendToCauseUsToNeedShowBadgeValue
{
   self.tabBarItem.badgeValue = @"Something";

}


written by: infinitywebseo 

View Controller Lifecycle

View Controllers are the controllers of your MVC. They have a Lifecycle. (They are created, do some task and they die.)

There are certain methods in view controller which notify you of what's going on. View controller can be created by alloc init by 99% of time MVCs are instantiated out of a story board.

Put set up codes for your view in viewDidLoad:

-(void) viewDidLoad{

 [super viewDidLoad];


}

But remember geometry is not set in viewDidLoad. You can do it in viewWillAppear:


-(void)viewWillAppear: (BOOL)animated;


Your view will only load once, but it may appear and disappear few times.
If your things you are displaying is changing while your app is off screen, you should add the code to viewWillAppear.


didRecievedMemoryWarning

In low memory situation, didRecievedMemoryWarning is called. It is very rare to happen, but if it happens you can set the pointer of the object that causes it to nil and reload your data. Keep in mind to use caching in your program where it makes sense.

awakeFromNib 

This message is sent to every single object that comes out of the story board. It happens before the MVC is loaded and before all the outlets are set.
written by: infinitywebseo 

Tuesday 30 April 2013

What is NSAttributedString ?

NSAttributedString is like a  NSString, expet every single character has dictionary of attributes. These attributes are things Like font, colour, underline, and etc.


How to get the attributes:
You can ask an NSAttributedString all about the attributes at a given location in the string.
- (NSDictinary  *)attributesAtIndex : (NSUInteger) index
                                   effectiveRange : (NSRangePointer) range;


Remember NSAttributedString is not an NSString, it does not inherits from NSString. So, you can not use NSString methods on it. However if you need to use NSString method, you must first turn NSAttributedString to NSString then use the method.
written by: infinitywebseo  

What is UIColor?

UIColor is a subclass of UIKit. Its an object which represent color. You can create it based on RGB or HSB and even patterns (UIImage).

Colors can also have alpha (UIColor *color = [otherColor colorWithAlphaComponent: 0.3]).

A handful of "standard" colors have class methods (e.g. [UIColor greenColor]).

written by: infinitywebseo  

What is NSRange?

NSRange is a C Struct,  it used to specify sub-ranges inside strings and arrays.

typedef struct {

  NSUInteger  location;
  NSUInteger lenght;

} NSRange;

Important location value is "NSNotFound".

NSString *myString = @"Hi Every One!" ;
NSString *search = @"Hello";

NSRange range = [greeting rangeOfString:search];

if (range.location == NSNotFound) {

// could not find search in myString

}

written by: infinitywebseo  

libxml2 vs NSxmlParser

Libxml2 is c base and NSxmlParser is a real cocoa class. Libxml2 is always faster than NSxmlParser in terms of performance. 

If performance is an is an issue, you should definitely use libxml2, but if you are only prosessing a small amount of data NSxmlParser is a better solution. NSxmlparser it ismuch easier to implement and understand.

written by: infinitywebseo  


What is NSDictionary?

If you are parsing xml data on your iOS program, please keep in mind that the code is slightly different when read xml file local from when you read it from a server.


Parsing Local XML file: ( xmlparser.m )


-(id) loadXMLByURL:(NSString *)urlString
{
   
   
    NSData *xmlData = [NSData dataWithContentsOfFile:urlString];
    NSXMLParser  *parser = [[NSXMLParser alloc] initWithData:xmlData];


    parser.delegate = self;
    [parser parse];
    return self;
   
}


Parsing  XML file from Server: ( xmlparser.m )


-(id) loadXMLByURL:(NSString *)urlString
{    
   
    NSData *xmlData = [NSData dataWithContentsOfFile:urlString];
    NSXMLParser  *parser = [[NSXMLParser alloc] initWithData:xmlData];


   NSURL *url = [NSURL URLWithString:urlString];
    NSXMLParser parser = [[NSXMLParser alloc]initWithContentsOfURL: url];


    parser.delegate = self;
    [parser parse];
    return self;
   
}


If you have any Questions please comment.


written by: infinitywebseo

(id) loadXMLByURL Method (local xml, xml on server)

If you are parsing xml data on your iOS program, please keep in mind that the code is slightly different when read xml file local from when you read it from a server.


Parsing Local XML file: ( xmlparser.m )


-(id) loadXMLByURL:(NSString *)urlString
{
   
   
    NSData *xmlData = [NSData dataWithContentsOfFile:urlString];
    NSXMLParser  *parser = [[NSXMLParser alloc] initWithData:xmlData];


    parser.delegate = self;
    [parser parse];
    return self;
   
}


Parsing  XML file from Server: ( xmlparser.m )


-(id) loadXMLByURL:(NSString *)urlString
{    
   
    NSData *xmlData = [NSData dataWithContentsOfFile:urlString];
    NSXMLParser  *parser = [[NSXMLParser alloc] initWithData:xmlData];


   NSURL *url = [NSURL URLWithString:urlString];
    NSXMLParser parser = [[NSXMLParser alloc]initWithContentsOfURL: url];


    parser.delegate = self;
    [parser parse];
    return self;
   
}


If you have any Questions please comment.


written by: infinitywebseo