Skip to content

Instantly share code, notes, and snippets.

View Duraiamuthan's full-sized avatar

Durai Amuthan Duraiamuthan

View GitHub Profile
@Duraiamuthan
Duraiamuthan / UDID Alternative
Last active August 29, 2015 13:58
UDID alternative in iOS 6+
Is UDID deprecated?
Yes. UDID is deprecated in iOS 5.
What are the alternatives?
identifierForVendor and advertisingIdentifier.
What is identifierForVendor?
@Duraiamuthan
Duraiamuthan / iOS 7 toolbar to iOS 6 toolbar converter
Created April 10, 2014 09:27
Convert iOS 7 toolbar's style to iOS 6
use the below code snippet inside the
application:didFinishLaunchingWithOptions:
[[UIToolbar appearance]setBackgroundImage:[UIImage imageNamed:@"toolBarImage.png"] forToolbarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
Download the toolBarImage from http://bit.ly/1lMdc5R
@Duraiamuthan
Duraiamuthan / SQLite ObjC DAL
Created April 21, 2014 15:56
SQLite Objective C Data Access Layer
//DAL.h
#import <UIKit/UIKit.h>
#import <sqlite3.h>
@interface DAL : NSObject
{
sqlite3* sqLiteObj;
NSString* dataBasePath;
}
@property(strong,nonatomic)NSString *DbName;
-(NSMutableArray *)RetrieveRecordswithSql:(NSString *)sql withColumnsCount:(NSNumber *)count andColumnsDelimiter:(NSString *)colDelimiter;
@Duraiamuthan
Duraiamuthan / JSON deserialization
Created April 21, 2014 16:01
NSData(JSON) to Objective C Object
NSData *dataJSON;
dataJSON=service output;
NSArray *arr=[NSJSONSerialization JSONObjectWithData:dataJSON options:kNilOptions error:&jsonParsingError];
@Duraiamuthan
Duraiamuthan / JSON serialization
Created April 21, 2014 16:03
Objective c object to json string serialization
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:ObjcObject options:NSJSONWritingPrettyPrinted error:&writeError];
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
@Duraiamuthan
Duraiamuthan / NSString+UrlEncode
Created April 21, 2014 16:08
Objective C UrlEncode Category
//header
@interface NSString (UrlEncode)
- (NSString *)urlencode;
@end
//implementation
#import "NSString+UrlEncode.h"
@Duraiamuthan
Duraiamuthan / CommonFunctions
Created April 21, 2014 16:14
Objective C CommonFunctions
//Header
#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
#import "NSString+UrlEncode.h"
@interface CommonFunctions:NSObject
+(void)MakeIOS6StyleStatusBar:(UIView*)vu;
@Duraiamuthan
Duraiamuthan / GeoLocation
Last active August 29, 2015 14:00
Objective C GeoLocations finder
//Header
#import <Foundation/Foundation.h>
#import "CoreLocation/CoreLocation.h"
@interface GeoLocation : NSObject<CLLocationManagerDelegate,UIAlertViewDelegate>
{
CLLocationManager *locationManager;
double latitude;
double longitude;
}
@Duraiamuthan
Duraiamuthan / MapAnnotation
Last active August 29, 2015 14:00
iOS Map Annotation
//header
@interface MKAnnotation : NSObject<MKAnnotation>
@property (strong, nonatomic) NSString *title;
@property (strong, nonatomic) NSString *subtitle;
@property (nonatomic,assign) CLLocationCoordinate2D coordinate;
-(id) initWithCoordinate:(CLLocationCoordinate2D)Coordinate title:(NSString *)Title andsubTitle:(NSString*)Subtitle;
@end
//implementation
@Duraiamuthan
Duraiamuthan / AddAnnotation
Last active August 29, 2015 14:00
AddAnnotation in Mapview
-(void)MarkMapwithLat:(NSString*)lat withLong:(NSString*)longi
{
NSLog(@"Latitude:%@ Longitude:%@",lat,longi);
CLLocationCoordinate2D coord=CLLocationCoordinate2DMake(lat.floatValue,longi.floatValue);
MKAnnotation *annotation=[[MKAnnotation alloc]initWithCoordinate:coord title:self.Name andsubTitle:customerSnippet];
MKCoordinateRegion viewRegion=MKCoordinateRegionMakeWithDistance(coord,500,500);