Moving Onto The Next UITextField When ‘Next’ Is Tapped

You need to make your view controller the UITextField delegate, and implement the UITextField delegate method: – (BOOL)textFieldShouldReturn:(UITextField *)textField { if (textField == nameField) { [textField resignFirstResponder]; [emailField becomeFirstResponder]; } else if (textField == emailField) { // here you can define what happens // when user presses return on the email field } return YES; … Read more

Shouldn’t NSUserDefault be clean slate for unit tests?

Using named suites like in this answer worked well for me. Removing the user defaults used for testing could also be done in func tearDown(). class MyTest : XCTestCase { var userDefaults: UserDefaults? let userDefaultsSuiteName = “TestDefaults” override func setUp() { super.setUp() UserDefaults().removePersistentDomain(forName: userDefaultsSuiteName) userDefaults = UserDefaults(suiteName: userDefaultsSuiteName) } }

AVURLAsset getting video size

Resolution in Swift 3: func resolutionSizeForLocalVideo(url:NSURL) -> CGSize? { guard let track = AVAsset(URL: url).tracksWithMediaType(AVMediaTypeVideo).first else { return nil } let size = CGSizeApplyAffineTransform(track.naturalSize, track.preferredTransform) return CGSize(width: fabs(size.width), height: fabs(size.height)) } For Swift 4: func resolutionSizeForLocalVideo(url:NSURL) -> CGSize? { guard let track = AVAsset(url: url as URL).tracks(withMediaType: else { return nil } let size … Read more