iOS Archives

These posts are syndicated from my iOS Dev Diary over at pinkstone.co.uk.

The format is slightly different with more code snippets and less explanations. I had originally designed it as a notebook in iOS Development – now you can follow along if you’re interested.

How to use the speech synthesiser in iOS 7

New to iOS 7′s AVFoundation Framework is the speech synthesiser. It’s what Siri is using when he/she speaks to you. We can use this as well in our apps by passing a string into an AVSpeechUtterance object, which in turn we pass into an AVSpeechSynthesizer instance. Here’s how: – (IBAction)sayThis:(id)sender { AVSpeechSynthesizer *synthesizer = [[AVSpeechSynthesizer […]

How to use the speech synthesiser in iOS 7

New to iOS 7′s AVFoundation Framework is the speech synthesiser. It’s what Siri is using when he/she speaks to you. We can use this as well in our apps by passing a string into an AVSpeechUtterance object, which in turn we pass into an AVSpeechSynthesizer instance. Here’s how: – (IBAction)sayThis:(id)sender { AVSpeechSynthesizer *synthesizer = [[AVSpeechSynthesizer […]

How to share items with a UIActivityViewController

Another option to share items in your app is to bring up a dialogue that contains several options, like the Photos app does: This is done with a UIActivityViewController and requires minimal work on our part. This controller is very clever and only brings up relevant services (you can’t print a video, or you can’t […]

How to post to Facebook and Twitter using Social Framework

It is extremely simple to bring up Facebook and Twitter Sheets in your app using the Social Framework. Once imported you can create a new instance of SLComposeViewController, initialise it with text, an image and a URL, and present it modally from your own view controller. You don’t have to specify anything other than which […]

How to test the size of a UIImage (in bytes)

We can use NSData’s length method for this. Imagine your UIImage is yourImage: NSData *imageData = UIImageJPEGRepresentation(yourImage, 1); NSLog(@”Size of your image is %d bytes”, [imageData length]) [imageData length] returns a double in bytes, which will be the size of your image. This is useful if you’d like to save something and you’re limited in […]

How to detect if your app is running on iOS 7

You can query the NSFoundationVersionNumber like so: if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) { // you’re running iOS 6.1 or earlier } else { // you’re running iOS 7 or later } Note that if you’re compiling with an older SDK, the value you’re querying may not be defined – in which case, you must define it […]