36 episodes

Join your friendly next-door hacker Jay Versluis for tips and tricks on iOS and macOS Development with Xcode and Objective-C.

The iOS Dev Diary Jay Versluis

    • Technology
    • 3.0 • 2 Ratings

Join your friendly next-door hacker Jay Versluis for tips and tricks on iOS and macOS Development with Xcode and Objective-C.

    Building a Day Counter on iOS – Part 3

    Building a Day Counter on iOS – Part 3

    In this series I’ll show you how to create a simple Day Counter on iOS, using Objective-C and Xcode 9. The idea is to set a date in a settings screen, and then see how many days have elapsed on the main screen right after launching the app.

    This is a 3-Part Mini-Series:



    * Part 1 is all about building the interface in Interface Builder

    * Part 2 is about coding the NSDate subtraction methods, using NSCalendar and loading/saving data using NSUserDefaults

    * Part 3 will introduce Key/Value Observing to update the first view controller as soon as the date is changed in the settings and deals with how to normalise an NSDate object.



    You can find the full code on GitHub:



    * https://github.com/versluis/Day-Counter/



    Happy Hacking!

    Watch the full course in one convenient playlist:Catch this episode on my iOS Dev Diary Podcast:

    • 19 min
    Building a Day Counter on iOS – Part 2

    Building a Day Counter on iOS – Part 2

    In this series I’ll show you how to create a simple Day Counter on iOS, using Objective-C and Xcode 9. The idea is to set a date in a settings screen, and then see how many days have elapsed on the main screen right after launching the app.

    This is a 3-Part Mini-Series:



    * Part 1 is all about building the interface in Interface Builder

    * Part 2 is about coding the NSDate subtraction methods, using NSCalendar and loading/saving data using NSUserDefaults

    * Part 3 will introduce Key/Value Observing to update the first view controller as soon as the date is changed in the settings and deals with how to normalise an NSDate object.



    You can find the full code on GitHub:



    * https://github.com/versluis/Day-Counter/



    Happy Hacking!

    Watch the full course in one convenient playlist:Catch this episode on my iOS Dev Diary Podcast:

    • 28 min
    Building a Day Counter on iOS – Part 1

    Building a Day Counter on iOS – Part 1

    In this series I’ll show you how to create a simple Day Counter on iOS, using Objective-C and Xcode 9. The idea is to set a date in a settings screen, and then see how many days have elapsed on the main screen right after launching the app.

    This is a 3-Part Mini-Series:



    * Part 1 is all about building the interface in Interface Builder

    * Part 2 is about coding the NSDate subtraction methods, using NSCalendar and loading/saving data using NSUserDefaults

    * Part 3 will introduce Key/Value Observing to update the first view controller as soon as the date is changed in the settings and deals with how to normalise an NSDate object.



    You can find the full code on GitHub:



    * https://github.com/versluis/Day-Counter/



    Happy Hacking!

    Watch the full course in one convenient playlist:Catch this episode on my iOS Dev Diary Podcast:

    • 19 min
    How to present a view controller on top of a UISplitView Controller – Part 2

    How to present a view controller on top of a UISplitView Controller – Part 2

    The second part of this mini-series about presenting another UIViewController on top of a UISplitViewController in iOS 9 and Xcode 7.

    Check out the first part here, complete with code snippets and a link to the full project.

    Enjoy!

    Watch the full course in one convenient playlist:Catch this episode on my iOS Dev Diary Podcast:

    • 12 min
    How to present a view controller on top of a UISplitView Controller – Part 1

    How to present a view controller on top of a UISplitView Controller – Part 1

    Since its introduction in iOS 5, our good friend the UISplitView Controller has always had a really annoying habit: it has to be the root view controller in our apps. This means that it cannot be presented from any other view controller, nor can the split view controller present other view controllers.

    This sucks because 99% of all apps probably need to present a user choice overlay at some point during the lifetime of an app. While some apps may get away with showing a Popover on iPad, many apps would be better off if we could present something like a proper form sheet as pictured in the image above. However, by Apple’s definition, that’s just not possible with the split view controller.

    Or is it…?

    In this screencast I’ll show you how to make it appear as if we could present another view controller over a UISplitView Controller. We’ll employ a bit of magic to create a great user experience, and it’s not really difficult either. The whole thing works on both iPhone and iPad with no extra work, and it works with apps in Slideover Mode too.

    At the bottom of the article I’ll show you the code snippets to make this magic happen, together with a fully working demo project.

    Enjoy!



     

    Code Snippets

    The app is based on the Xcode Master/Detail template. Aside from hooking up two buttons to present and dismiss the overlay, all methods are conveniently called in AppDelegate. We need three methods in total.

    The first one will create a screenshot of whatever is currently on screen and return it as a UIImage:- (UIImage *)grabScreenshot {



    // create graphics context with screen size

    CGRect screenRect = [[UIScreen mainScreen] bounds];

    UIGraphicsBeginImageContext(screenRect.size);

    CGContextRef ctx = UIGraphicsGetCurrentContext();

    [[UIColor blackColor] set];

    CGContextFillRect(ctx, screenRect);



    // grab reference to our window

    UIWindow *window = [UIApplication sharedApplication].keyWindow;



    // transfer content into our context

    [window.layer renderInContext:ctx];

    UIImage *screengrab = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();



    return screengrab;

    }I’m explaining how this method works and what it does  in this article.

    The next two methods need to be public, so let’s make sure their signature appears in our AppDelegate.h file, anywhere before the @end:- (void)showOverlay;

    - (void)dismissOverlay;Back in our AppDelegate.m file, here’s the first method:- (void)showOverlay {



    // grab a screenshot

    UIImage *screenshot = [self grabScreenshot];



    // create a new view controller with it

    UIViewController *underlay = [[UIViewController alloc]init];

    UIImageView *background = [[UIImageView alloc]initWithImage:screenshot];

    underlay.view = background;



    // grab the overlay controller

    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];

    UINavigationController *overlay = (UINavigationController *)[storyboard instantiateViewControllerWithIdentifier:@"Overlay"];

    overlay.modalPresentationStyle = UIModalPresentationFormSheet;



    // swap the split view

    self.splitView = (UISplitViewController *)self.window.rootViewController;

    self.window.rootViewController = underlay;



    // present the overlay

    [underlay presentViewController:overlay animated:YES completion:nil];

    }Here we grab a screenshot using our previous method and create a brand new...

    • 17 min
    Building a searchable UITableView in iOS 9 – Part 4

    Building a searchable UITableView in iOS 9 – Part 4

    In this final part of our project we’ll finish off the app by implementing a little Key Value Observation magic. This will let us update our second UITableViewController when new search results are to be displayed.

    Check out the first part here, as well as a link to my demo project.

    Enjoy!

    Watch the full course in one convenient playlist:Catch this episode on my iOS Dev Diary Podcast:

    • 11 min

Customer Reviews

3.0 out of 5
2 Ratings

2 Ratings

Top Podcasts In Technology

Lex Fridman Podcast
Lex Fridman
All-In with Chamath, Jason, Sacks & Friedberg
All-In Podcast, LLC
Acquired
Ben Gilbert and David Rosenthal
Deep Questions with Cal Newport
Cal Newport
In Her Ellement
Boston Consulting Group BCG
Hard Fork
The New York Times