This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
@interface SampleClass : NSObject | |
- (id)init __attribute__((unavailable("init is unavailable"))); | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSNumberFormatter *currencyFormatter = [[[NSNumberFormatter alloc] init] autorelease]; | |
[currencyFormatter setNumberStyle:NSNumberFormatterCurrencyStyle]; | |
double d2 = 3432.89; | |
NSString *strCurrency = [currencyFormatter stringFromNumber:[NSNumber numberWithDouble:d2]]; | |
NSLog(@"%@", strCurrency); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSNumberFormatter *formatter = [[[NSNumberFormatter alloc] init] autorelease]; | |
[formatter setNumberStyle:NSNumberFormatterDecimalStyle]; | |
double d =324233.89; | |
int i = 324324324; | |
NSString *strFloat = [formatter stringFromNumber:[NSNumber numberWithDouble:d]]; | |
NSString *strInt = [formatter stringFromNumber:[NSNumber numberWithInt:i]]; | |
NSLog(@"Float: %@", strFloat); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(BOOL)Contains:(NSString *)StrSearchTerm on:(NSString *)StrText | |
{ | |
return [StrText rangeOfString:StrSearchTerm options:NSCaseInsensitiveSearch].location==NSNotFound?FALSE:TRUE; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSAlert *alert=[NSAlert alertWithMessageText:@"message" defaultButton:@"Ok" alternateButton:@"Cancel" otherButton:nil informativeTextWithFormat:@"InformativeText"]; | |
NSInteger i=[alert runModal]; | |
if (i==NSAlertDefaultReturn) { | |
NSLog(@"Ok pressed"); | |
} | |
else{ | |
NSLog(@"Else pressed"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CFUUID | |
CFUUID is available from iOS 2.0. CoreFoundation package (C style API) provide CFUUID. CFUUIDCreate is the method to create the CFUUIDRef and can get an NSString representation of the created CFUUIDRef like :- | |
CFUUIDRef cfuuid = CFUUIDCreate(kCFAllocatorDefault); | |
NSString *cfuuidString = (NSString*)CFBridgingRelease(CFUUIDCreateString(kCFAllocatorDefault, cfuuid)); | |
CFUUID is not persisted, every time you call CFUUIDCreate and will get new unique identifier. | |
e.g. 68883Q11-4D23-5434-9D60-2250E4C90967 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//SFHFKeychainUtils.h | |
#import <UIKit/UIKit.h> | |
@interface SFHFKeychainUtils : NSObject { | |
} | |
+ (NSString *) getPasswordForUsername: (NSString *) username andServiceName: (NSString *) serviceName error: (NSError **) error; | |
+ (BOOL) storeUsername: (NSString *) username andPassword: (NSString *) password forServiceName: (NSString *) serviceName updateExisting: (BOOL) updateExisting error: (NSError **) error; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# https://gist.github.com/949831 | |
# http://blog.carbonfive.com/2011/05/04/automated-ad-hoc-builds-using-xcode-4/ | |
# command line OTA distribution references and examples | |
# http://nachbaur.com/blog/how-to-automate-your-iphone-app-builds-with-hudson | |
# http://nachbaur.com/blog/building-ios-apps-for-over-the-air-adhoc-distribution | |
# http://blog.octo.com/en/automating-over-the-air-deployment-for-iphone/ | |
# http://www.neat.io/posts/2010/10/27/automated-ota-ios-app-distribution.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(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); | |