Commits

paradoxiology committed 5eec832

Update Objective-C snippets

  • Participants
  • Parent commits dbfdc78

Comments (0)

Files changed (1)

File vim/UltiSnips/objc.snippets

 NSLog(@"$1"${1/[^%]*(%)?.*/(?1:, :\);)/}$2${1/[^%]*(%)?.*/(?1:\);)/}
 endsnippet
 
-snippet alert "NSRunAlertPanel (alert)"
-int choice = NSRunAlertPanel(@"${1:Something important!}", @"${2:Something important just happend, and now I need to ask you, do you want to continue?}", @"${3:Continue}", @"${4:Cancel}", nil);
-if(choice == NSAlertDefaultReturn) // "$3"
-{
-	$0;
-}
-else if(choice == NSAlertAlternateReturn) // "$4"
-{
-	
-}
+snippet alert "UIAlertView Initialisation (alert)"
+UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"$1"
+													message:@"$2"
+												   delegate:nil
+										  cancelButtonTitle:@"$3"
+										  otherButtonTitles:@"$4", nil];
+[alertView show];
 endsnippet
 
 snippet format "NSString stringWithFormat (format)"
 [[NSUserDefaults standardUserDefaults] objectForKey:${1:key}];
 endsnippet
 
-snippet obs "Register for Notification"
-[[NSNotificationCenter defaultCenter] addObserver:${1:self} selector:@selector(${3:${2/^([A-Z]{2})?(.+?)(Notification)?$/\l$2/}}:) name:${2:NSWindowDidBecomeMainNotification} object:${4:nil}];
-endsnippet
-
 snippet responds "Responds to Selector"
 if ([${1:self} respondsToSelector:@selector(${2:someSelector:})])
 {
     $2
 }
 endsnippet
+
+snippet post "Post Notification through NSNotificationCenter" !b
+[[NSNotificationCenter defaultCenter] postNotificationName:${1:notifName}
+													object:${2:self}
+												  userInfo:${3:nil}];
+
+endsnippet
+
+snippet obs "Register for Notification"
+[[NSNotificationCenter defaultCenter] addObserver:${1:self}
+                                         selector:@selector(${3:${2/^([A-Z]{2})?(.+?)(Notification)?$/\l$2/}}:)
+                                             name:${2:notifName}
+                                           object:${4:nil}];
+endsnippet
+
 # vim:ft=snippets: