1 NSUserDefaults
[[NSUserDefaults standardUserDefaults] boolForKey:kHomeButtonSetting]
[[NSUserDefaults standardUserDefaults] setBool:self.isVoiceMode forKey:kHomeButtonSetting];
2 NSMutableArray
NSArray *array= [[NSUserDefaults standardUserDefaults] arrayForKey:SELES_CITYS] ;
self.historys = [NSMutableArray arrayWithArray:array] ;
//保证栈的顺序
if ([self.historys containsObject:city]) {
[self.historys removeObject:city];
}
if (self.historys.count >=5) {
[self.historys removeLastObject];
}
[self.historys insertObject:city atIndex:0 ];
[[NSUserDefaults standardUserDefaults] setObject:self.historys forKey:SELES_CITYS];
3 NSDictionary
NSString *path=[[NSBundle mainBundle] pathForResource:@"citydict"
ofType:@"plist"];
cities = [[NSDictionary alloc]initWithContentsOfFile:path];
keys = [[cities allKeys] sortedArrayUsingSelector:@selector(compare:)];
4 NSBundle
NSString *path=[[NSBundle mainBundle] pathForResource:@"citydict"
ofType:@"plist"];
let path = NSBundle.mainBundle().pathForResource(name, ofType:ext)
2015年6月10日
NSString* networkPath = [[NSBundle mainBundle] pathForResource:@"jetpac" ofType:@"ntwk"];
if (networkPath == NULL) {
fprintf(stderr, "Couldn't find the neural network parameters file - did you add it as a resource to your application?\n");
assert(false);
}
network = jpcnn_create_network([networkPath UTF8String]);
5 NSNotificationCenter
[[NSNotificationCenter defaultCenter] postNotificationName:@"com.chinaso.showListener" object:nil];
NSNotificationCenter.defaultCenter().addObserverForName("com.chinaso.showListener", object: nil, queue: NSOperationQueue.mainQueue()) { (notification:NSNotification!) -> Void in
self.voice()
}
NSNotificationCenter.defaultCenter().addObserverForName("com.chinaso.showScaner", object: nil, queue: NSOperationQueue.mainQueue()) { (notification:NSNotification!) -> Void in
self.barcode()
6 Local NSNotification
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
//注册申请 local notification
if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)]) {
[application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert |UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil]];
}
[UIApplication sharedApplication].applicationIconBadgeNumber=0 ;
return YES;
}
// 在后端,当用户点击通知时候,收到
-(void) application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
NSLog(@"%@" ,notification) ;
[UIApplication sharedApplication].applicationIconBadgeNumber=8;
}
-(void) doSendNotifaction {
UILocalNotification *notifcation = [[UILocalNotification alloc] init];
notifcation.fireDate = [NSDate dateWithTimeIntervalSinceNow:10] ;
notifcation.alertBody = @"测试 local notification" ;
// [[UIApplication sharedApplication] scheduledLocalNotifications:notifcation];
[[UIApplication sharedApplication] scheduleLocalNotification:notifcation];
}