-1

When I change my project deployment target from iOS 8.4 to iOS 9.0 I receive a lot of error messages, such as:

'initWithRequest:delegate:startImmediately:' is deprecated: first deprecated in iOS 9.0 - Use NSURLSession (see NSURLSession.h)

- (void)operationDidStart {
[self.lock lock];
if (![self isCancelled]) {
    self.connection = [[NSURLConnection alloc] initWithRequest:self.request delegate:self startImmediately:NO];

    NSRunLoop *runLoop = [NSRunLoop currentRunLoop];
    for (NSString *runLoopMode in self.runLoopModes) {
        [self.connection scheduleInRunLoop:runLoop forMode:runLoopMode];
        [self.outputStream scheduleInRunLoop:runLoop forMode:runLoopMode];
    }

    [self.outputStream open];
    [self.connection start];
}
[self.lock unlock];

dispatch_async(dispatch_get_main_queue(), ^{
    [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidStartNotification object:self];
});
}

'UIAlertView' is deprecated: first deprecated in iOS 9.0 - UIAlertView is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert instead

UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:nil delegate:delegate cancelButtonTitle:cancelButtonTitle otherButtonTitles:nil, nil];

'init' is deprecated: first deprecated in iOS 9.0 - Use -initWithConcurrencyType: instead

_managedObjectContext = [[NSManagedObjectContext alloc] init];

'initWithRequest:delegate:' is deprecated: first deprecated in iOS 9.0 - Use NSURLSession (see NSURLSession.h)

NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];

Any help with any of these errors would be greatly appreciated.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Creagen
  • 478
  • 5
  • 17
  • 1
    1) Why are you dropping support for iOS 8 already? 2) Read the docs for the deprecated methods. The docs usually tell you what to use in their place. – rmaddy Sep 17 '15 at 01:36
  • 3
    These are not error messages, they are warnings. You need to check the documentation for iOS9 which will explicitly tell you what the alternative for the deprecated methods and classes are. There's nothing that you need to do right now but over a period of time these deprecated items will be removed from the SDK so you will eventually need to migrate them to their alternatives. – Rog Sep 17 '15 at 01:37
  • I'm not dropping support. I want the app to support iOS 9 and below. – Creagen Sep 17 '15 at 01:37
  • 2
    When you set deployment target to iOS 9 it means you app will only support iOS 9 and above, not below. Leave it as it was and test your app on an iOS 9 device for compatibility issues. – Rog Sep 17 '15 at 01:38
  • 3
    To add to what @Rog stated - lookup the difference between Deployment Target and Base SDK. Also read the "SDK Compatibility Guide" in the iOS docs. – rmaddy Sep 17 '15 at 01:49
  • My Base SDK is set to Latest which right now is iOS 9. Should I set my deployment target to 8.0 just incase some people haven't updated? – Creagen Sep 17 '15 at 02:00
  • 2
    Yes. It will takes months for a majority to upgrade to iOS 9. But there will always be those that don't or can't upgrade so supporting iOS 8 should be done for at least a year if not longer (depends on your app and your audience). – rmaddy Sep 17 '15 at 02:04
  • Alright. And to do that I just set my Projects deployment target and my Targets deployment target to iOS 8.0, correct? – Creagen Sep 17 '15 at 02:05
  • 2
    Yes, that is correct. – rmaddy Sep 17 '15 at 02:28

1 Answers1

0

In iOS 9 instead of UIAlertView you use UIAlertViewController:

UIAlertController *alertView= [UIAlertController
                                      alertControllerWithTitle:title
                                      message:message
                                      preferredStyle:UIAlertControllerStyleAlert];
[alertView addAction: [UIAlertAction actionWithTitle:otherButtonTitle
               style:UIAlertActionStyleDefault
               handler:^(UIAlertAction * action)
               {

               }]];
[self presentViewController:alertView animated:YES completion:nil];
Wyetro
  • 8,439
  • 9
  • 46
  • 64