Health Update

Dear friends,

I have some bad news I feel I must share with you: earlier this year I was diagnosed with colon cancer. I’ve spent most of February in hospital for two major operations to remove several tumours and fistulas, and I’m waiting for chemo and radiotherapy to start. The surgery alone has put a major strain on my body and my mind, and I’m not sure how I will react to the next few months of treatment.

This means that I will not be able to write as much content here as I have in the past, if I can produce any content at all. I know this sucks for you as much as it does for me. I’ve been battling with this disease since last year without knowing what it was at that time, and this is reflected in the reduced number of articles I’ve written in 2015.

I will let you know as soon as I feel better, but I fear that it will take the remainder of this year (2016) until I’m whipped back into shape. I have wonderful doctors who look after me, and good health insurance too, who have so far covered all expenses of this distasteful affair. Thank god for that!

If you feel that you’ve been “cheated out of your membership”, please contact me and we’ll work something out. If you need alternatives for learning iOS development, please look into the likes of Lynda.com and Pluralsight.com, who update much more frequently than I ever could. At the same time, they charge you more per month than what I’m asking for in a year to cover the cost of hardware and hosting. And: they’re professional teachers, whereas I am hobbyist hacker.

Thank you for your understanding, and thank you for your loyal support.

All the best, and Happy Hacking,

 

JAY

How to read MFi Controller input in iOS

Nimbus ControllerI bought a SteelSeries Nimbus controller the other day. It’s Made For iOS (MFi) and supported by many games, including those on OS X and tvOS.

Seriously, it’s a phenomenal controller! Naturally I wanted to see how easy (or difficult) it was to use it in my own projects.

Turns out that for game developers, it’s not that tough to make it work – thanks to Apple’s great GameController Framework that was introduced in iOS 7.

Here’s how I did it, following Apple’s document called Game Controller Programming Guide.

Continue reading

How to avoid “Capturing ‘self’ strongly in this block is likely to lead to a retain cycle”

I was trying to update a UILabel from inside a block the other day, and was puzzled by the above Xcode warning: “Capturing ‘self’ strongly in this block is likely to lead to a retain cycle”. The full code looked like this:

 

self.mainController.controllerPausedHandler = ^(GCController *controller){

        // triggers a warning
        [self displayMessage:@"Pause Button"];

    };

As it turns out, the trouble was that a block executed in self cannot capture a reference to itself (self) without there being a never ending loop involved. It’s probably to complicated for me to understand and/or care about, but thankfully there’s a relatively easy way to correct this problem.

Continue reading

How to play videos in iOS 9

Until iOS 8 we could use the trusty old MPMoviePLayerViewController class to play videos on our devices, but that’s been deprecated in iOS 9. From now on, Apple recommend we use the AVPlayerViewController class instead. It has many advantages and even supports picture-in-picture out of the box.

Although AVPlayerViewController is a subclass of UIViewController, instances of it cannot be presented using presentViewController – but Apple make sure not to mention this little tidbit. It’s much more “fun” to figure this out on our own.

Here’s how we can use it with a local video from the main bundle:

@import AVFoundation;
@import AVKit;

// ...

// grab a local URL to our video
NSURL *videoURL = [[NSBundle mainBundle]URLForResource:@"video" withExtension:@"mp4"];

// create an AVPlayer
AVPlayer *player = [AVPlayer playerWithURL:videoURL];

// create a player view controller
AVPlayerViewController *controller = [[AVPlayerViewController alloc]init];
controller.player = player;
[player play];

// show the view controller
[self addChildViewController:controller];
[self.view addSubview:controller.view];
controller.view.frame = self.view.frame;

First we grab a URL to either a local or remote video. Next we create an AVPlayer with this URL, and add said player to the newly created AVPlayerViewController instance. You can auto-play a video by using the player’s play method, or remove it and leave it up to the user to start the video.

Next we’ll present the controller by adding it as a subview to our current view, making sure it has the same frame size.

The class works equally well with local and remote URLs. To play a remote asset, construct the URL like this:

NSURL *videoURL = [NSURL URLWithString:@"https://github.com/versluis/Movie-Player/blob/master/Movie%20Player/video.mov?raw=true"];

What’s new in iOS 9.2

This update contains improvements and bug fixes including:

Apple Music improvements

  • You can now create a new playlist when adding a song to a playlist
  • Your most recently changed playlist is now listed at the top when adding songs to playlists
  • Download albums or playlists from your iCloud Music Library by tapping the iCloud download button
  • See which songs have been downloaded with the new download indicator next to each song in My Music and Playlists
  • See works, composers, and performers while browsing Classical music in the Apple Music catalog

General improvements

  • A new Top Stories section in News so you can stay up to date with the most important news of the day (available in the United States, United Kingdom, and Australia)
  • Mail Drop in Mail for sending large attachments
  • iBooks now supports 3D Touch to peek and pop pages from the table of contents, your notes and bookmarks, or from search results inside a book
  • iBooks now supports listening to an audiobook while you browse your library, read other books, or explore the iBooks Store
  • iPhone support for the USB Camera Adapter to import photos and videos
  • Improved stability of Safari
  • Improved stability of Podcasts
  • Fixing an issue that caused mail attachments to be inaccessible for some users with POP email accounts
  • Resolving an issue for some users that caused attachments to overlap text in mail
  • Fixing an issue where Live Photos could have turned off after restoring from a previous iCloud backup
  • Addressing an issue that could cause search in Contacts to display no results
  • Resolving an issue that could have prevented Calendar from displaying all seven days in week view
  • Fixing an issue where Camera screen on iPad could be black when attempting to capture video
  • Addressing an issue that could cause instability in the Activity app when viewing the day of Daylight Savings Time transition
  • Fixing an issue that could prevent data from appearing in Health
  • Fixing an issue that could prevent Wallet updates and Lock screen alerts from displaying
  • Addressing an issue where updating iOS could prevent an alarm from going off
  • Fixing an issue where some users were unable to login to Find my iPhone
  • Fixing an issue that prevented some manual iCloud Backups from completing
  • Addressing an issue where using the iPad keyboard could unintentionally trigger text selection mode
  • Improved keyboard responsiveness when using Quick Reply
  • Improved punctuation input on the 10-key Chinese (Pinyin & Stroke) keyboards with new expanded view of punctuation symbols and better predictions
  • Fixing an issue on Cyrillic keyboards where caps lock would be enabled when typing in URL or email fields

Accessibility improvements

  • Fixing issues with VoiceOver when using Camera face detection
  • Adding support for VoiceOver to wake up the screen
  • Adding support for VoiceOver to invoke app switcher with 3D Touch gesture
  • Fixing an issue with Guided Access when trying to end phone calls
  • Improved functionality for Switch Control users when using 3D Touch
  • Fixing an issue with speech rate of Speak Screen
  • Siri support for Arabic (Saudi Arabia, United Arab Emirates)

For information on the security content of this update, please visit this website:
https://support.apple.com/HT201222