-1

当我将项目部署目标从 iOS 8.4 更改为 iOS 9.0 时,我收到很多错误消息,例如:

'initWithRequest:delegate:startImmediately:' 已弃用:首先在 iOS 9.0 中弃用 - 使用 NSURLSession(参见 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' 已弃用:首先在 iOS 9.0 中弃用 - UIAlertView 已弃用。改用 UIAlertController 和 UIAlertControllerStyleAlert 的preferredStyle

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

'init' 已弃用:首先在 iOS 9.0 中弃用 - 使用 -initWithConcurrencyType: 代替

_managedObjectContext = [[NSManagedObjectContext alloc] init];

'initWithRequest:delegate:' 已弃用:首先在 iOS 9.0 中弃用 - 使用 NSURLSession(参见 NSURLSession.h)

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

任何这些错误的帮助将不胜感激。

4

1 回答 1

0

在 iOS 9 中,而不是UIAlertView您使用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];
于 2015-09-17T15:41:15.497 回答