Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Faster cocoa app development

sarperdag
December 22, 2012

Faster cocoa app development

Slides from my talk on faster native cocoa apps development at the 3rd cocoaist meeeting in Istanbul.

sarperdag

December 22, 2012
Tweet

More Decks by sarperdag

Other Decks in Programming

Transcript

  1. AFNetworking NSURL  *url  =  [NSURL  URLWithString:@"https://alpha-­‐api.app.net/stream/0/posts/stream/global"]; NSURLRequest  *request  =  [NSURLRequest

     requestWithURL:url]; AFJSONRequestOperation  *operation  =  [AFJSONRequestOperation   JSONRequestOperationWithRequest:request  success:^(NSURLRequest  *request,  NSHTTPURLResponse   *response,  id  JSON)  {        NSLog(@"App.net  Global  Stream:  %@",  JSON); }  failure:nil]; [operation  start]; https://github.com/AFNetworking/AFNetworking
  2. FSNetworking https://github.com/foursquare/FSNetworking NSURL  *url            

                       =  ...;  //  required NSDictionary  *headers          =  ...;  //  optional NSDictionary  *parameters    =  ...;  //  optional FSNConnection  *connection  = [FSNConnection  withUrl:url                                method:FSNRequestMethodGET                              headers:headers                        parameters:parameters                        parseBlock:^id(FSNConnection  *c,  NSError  **error)  {                                return  [c.responseData  dictionaryFromJSONWithError:error];                        }              completionBlock:^(FSNConnection  *c)  {                      NSLog(@"complete:  %@\n    error:  %@\n    parseResult:  %@\n",  c,  c.error,   c.parseResult);              }                  progressBlock:^(FSNConnection  *c)  {                          NSLog(@"progress:  %@:  %.2f/%.2f",  c,  c.uploadProgress,   c.downloadProgress);                  }]; [connection  start];
  3. RestKIT @interface  Tweet  :  NSObject @property  (nonatomic,  copy)  NSNumber  *userID;

    @property  (nonatomic,  copy)  NSString  *username; @property  (nonatomic,  copy)  NSString  *text; @end RKObjectMapping  *mapping  =  [RKObjectMapping  mappingForClass:[RKTweet  class]]; [mapping  addAttributeMappingsFromDictionary:@{        @"user.name":      @"username",        @"user.id":          @"userID",        @"text":                @"text" }]; RKResponseDescriptor  *responseDescriptor  =  [RKResponseDescriptor  responseDescriptorWithMapping:mapping  pathPattern:nil   keyPath:nil  statusCodes:nil]; NSURL  *url  =  [NSURL  URLWithString:@"http://api.twitter.com/1/statuses/public_timeline.json"]; NSURLRequest  *request  =  [NSURLRequest  requestWithURL:url]; RKObjectRequestOperation  *operation  =  [[RKObjectRequestOperation  alloc]  initWithRequest:request   responseDescriptors:@[responseDescriptor]];   [operation  setCompletionBlockWithSuccess:^(RKObjectRequestOperation  *operation,  RKMappingResult  *result)  {        NSLog(@"The  public  timeline  Tweets:  %@",  [result  array]); }  failure:nil]; [operation  start]; https://github.com/RestKit/RestKit
  4. MBProgressHUD https://github.com/jdg/MBProgressHUD MBProgressHUD  *hud  =  [MBProgressHUD   showHUDAddedTo:self.view  animated:YES]; hud.mode

     =  MBProgressHUDModeAnnularDeterminate; hud.labelText  =  @"Loading"; [self   doSomethingInBackgroundWithProgressCallback:^(float   progress)  {        hud.progress  =  progress; }  completionCallback:^{        [MBProgressHUD  hideHUDForView:self.view   animated:YES]; }];
  5. SVPullToRefresh https://github.com/samvermette/SVPullToRefresh [tableView  addPullToRefreshWithActionHandler:^{        //  prepend  data

     to  dataSource,  insert  cells  at  top  of  table  view        //  call  [tableView.pullToRefreshView  stopAnimating]  when  done }];
  6. NUI @primaryFontName:  HelveticaNeue; @secondaryFontName:  HelveticaNeue-­‐Light; @primaryFontColor:  #333333; @primaryBackgroundColor:  #E6E6E6; Button

     {        background-­‐color:  @primaryBackgroundColor;        border-­‐color:  #A2A2A2;        border-­‐width:  @primaryBorderWidth;        font-­‐color:  @primaryFontColor;        font-­‐color-­‐highlighted:  #999999;        font-­‐name:  @primaryFontName;        font-­‐size:  18;        corner-­‐radius:  7; } NavigationBar  {        background-­‐tint-­‐color:  @primaryBackgroundColor;        font-­‐name:  @secondaryFontName;        font-­‐size:  20;        font-­‐color:  @primaryFontColor;
  7. PSTCollectionView https://github.com/steipete/PSTCollectionView Open Source, 100% API compatible replacement of UICollectionView

    for iOS4.3+ UICollectionViewFlowLayout  *flowLayout  =   [UICollectionViewFlowLayout  new]; PSTCollectionView  *collectionView  =   [PSTCollectionView  alloc]   initWithFrame:self.view.bounds   collectionViewLayout: (PSTCollectionViewFlowLayout  *)flowLayout];
  8. BlockAlerts https://github.com/gpambrozio/BlockAlertsAnd- ActionSheets BlockAlertView  *alert  =  [BlockAlertView  alertWithTitle:@"Alert  Title"  

                                                                                               message:@"This  is  a  very  long   message,  designed  just  to  show  you  how  smart  this  class  is"]; [alert  addButtonWithTitle:@"Do  something  cool"  block:^{        //  Do  something  cool  when  this  button  is  pressed }]; [alert  setCancelButtonWithTitle:@"Please,  don't  do  this"  block:^{        //  Do  something  or  nothing....  This  block  can  even  be  nil! }]; [alert  setDestructiveButtonWithTitle:@"Kill,  Kill"  block:^{        //  Do  something  nasty  when  this  button  is  pressed }];
  9. SEHumanizedTimeDiff https://github.com/sarperdag/SEHumanizedTimeDiff //1  minute myLabel.text  =  [[NSDate  dateWithTimeIntervalSinceNow:-­‐360]    

                               stringWithHumanizedTimeDifference:NSDateHumanizedSuffixNone                                withFullString:NO]; //This  will  return  @"1m" //2  days myLabel.text  =  [[NSDate  dateWithTimeIntervalSinceNow:-­‐3600*24*2]                                stringWithHumanizedTimeDifference:NSDateHumanizedSuffixAgo                                withFullString:YES]; //This  will  return  @"2  days  ago"
  10. STTweetLabel https://github.com/ SebastienThiebaud/STTweetLabel/ STTweetLabel  *tweetLabel  =  [[STTweetLabel  alloc]  initWithFrame:CGRectMake(20.0,  

    60.0,  280.0,  200.0)];        [tweetLabel  setFont:[UIFont  fontWithName:@"HelveticaNeue"  size:17.0]];        [tweetLabel  setTextColor:[UIColor  blackColor]];        [tweetLabel  setDelegate:self];        [tweetLabel  setText:@"Hi.  This  is  a  new  tool  for  @you!  Developed  by-­‐ >@SebThiebaud  for  #iPhone  #ObjC...  ;-­‐)  My  GitHub  page:  https://t.co/pQXDoiYA"];        [self.view  addSubview:tweetLabel];
  11. iRate https://github.com/nicklockwood/iRate iRate is a library to help you promote

    your iPhone and Mac App Store apps by prompting users to rate the app after using it for a few days. This approach is one of the best ways to get positive app reviews by targeting only regular users (who presumably like the app or they wouldn't keep using it!).
  12. iOSImageFilters https://github.com/esilverberg/ios-image-filters #import  "ImageFilter.h" UIImage  *image  =  [UIImage   imageNamed:@"landscape.jpg"];

    self.imageView.image  =  [image  sharpen]; //  Or self.imageView.image  =  [image  saturate: 1.5]; //  Or self.imageView.image  =  [image  lomo];