TimesToCome Mobile

iOS apps and tips, tricks and tools for smart phones

Archive for the ‘How to’ Category

Swift data to C pointer and back again

without comments

I’ve been converting my hardware sensor app from ObjC to Swift. Today I converted the sound which was easier than expected till I had to de-reference the data pointer. Hours later I have it working.

Here are the basics for converting back and forth from C pointers and Swift

let data:UInt8 = 42 // Swift 8bit int
let ps = UnsafeMutablePointer.alloc(1) // alloc one memory location
ps.initialize(data) // put the data in the memory location

let dataOut = UnsafeMutablePointer(ps) // cast the C pointer to Swift pointer
let original:UInt8 = ps.memory // grab the data and cast it to a Swift Int8

// ———— for sound capture ———————————————–

func captureOutput(captureOutput: AVCaptureOutput!, didOutputSampleBuffer sampleBuffer: CMSampleBuffer!, fromConnection connection: AVCaptureConnection!) {

let formatDescriptionRef = CMSampleBufferGetFormatDescription(sampleBuffer)
let formatDescription = CMAudioFormatDescriptionGetStreamBasicDescription(formatDescriptionRef)

var totalBytes = 0 as UInt64

let blockBufferRef = CMSampleBufferGetDataBuffer(sampleBuffer)
var lengthOfBlock = CMBlockBufferGetDataLength(blockBufferRef)

var data = NSMutableData(length: Int(lengthOfBlock))
CMBlockBufferCopyDataBytes(blockBufferRef, 0, lengthOfBlock, data.mutableBytes)

var samples = UnsafeMutablePointer(data.mutableBytes)
var value:UInt8 = samples.memory

}

Written by Linda MacPhee-Cobb

October 3rd, 2014 at 2:30 pm

Posted in How to,programming

The best of the iOS7 tips and tricks

without comments

1) In messages, in a conversation swipe right to left and hold to see the time the message was sent.

2) In Safari, tap bookmarks, see the ‘@’ at the top right? Tap that to see links in your Twitter feed

3) Settings->Privacy->Advertising – Limit Ad Tracking

4) Settings->Phone->Blocked ( I set up one contact and put all the spam numbers in there, then blocked the spam contact )

5) Set up a silent ringtone for contacts you don’t want to hear from

6) Push alerts up to make them vanish – no more waiting for the 5 second time out

7) Calendar list view is still here, tap the search button at the top of calendar to view your list

8) Tap the temperature in the weather application to get humidity, wind speed, chance of rain information.

Apple just started an iPhone 5S Tips and Tricks page

Written by Linda MacPhee-Cobb

September 18th, 2013 at 4:53 pm

Posted in How to,iPhone help

iPhone 5 iOS 6 tips and tricks

without comments

1) To quickly lock your device click the power off button

2) To quickly open the camera when the device is locked -> click the power off button -> swipe up on the camera icon next to the unlock slider at the bottom

3) To change the volume while locked double click the home button

4) To add keyboard shortcuts ( type a few letters and it will autofill in the rest of the text for you ) go to Settings->General->Keyboard->Shortcuts

5) To dictate Siri must be on ( Settings->General->Siri ) and you must be connected to the internet. A microphone will appear on your keyboard – tap it to begin dictating

6) To turn off notifications from appearing in the notification center go to Settings->Notifications->(chose the app to remove) ->Select none for the Alert style, then turn notification center off

7) Press the on/off button to silence a ringing phone, press twice quickly to send the call straight to voice mail

8) Block calls but not the internet ->Settings-> (turn airplane mode on) Go to WiFi and turn it on

9) To use a different signature on different email accounts go to Settings->Mail,Contacts,Calendars->Signature and check Per Account

10) To get written map directions instead of spoken, tap the icon that looks like a list next to the 3D icon on the bottom left of the maps view

11) Go to Settings->Maps and change the label size ( scroll to bottom) to small to get more detail on your maps

For a whole lot more information see:
iPhone User Guide

Written by Linda MacPhee-Cobb

September 25th, 2012 at 6:03 pm

Posted in How to,iPhone help

Where to trade in your old gadgets for money

without comments

Now that you have the newest, latest, iPad, iPhone, Kindle, etc what do you do with the old one?

You can trade them in for an Amazon.com gift card Amazon Electronics Trade in

Or you might try eBay Instant Sale which will give you cash back via PayPay.

Written by Linda MacPhee-Cobb

March 21st, 2012 at 8:40 am