こんにちは、現在、新しいビューを画面にプッシュしようとしているコード行に警告があります。概要 // 私の NSObject は、私が設定したサーバーから code=1 を受け取ります。すべてが正常に機能し、コードが通過して AlertView メッセージのボタンクリックをキャッチする if ステートメントを設定した AlertView を初期化します。そのボタンが押されると、私のアプリケーションは落ちます。
ヘッダー ファイルにプッシュしようとしているビューの ViewController を宣言しましたが、コンパイル時に警告だけでエラーは発生しません。
これは私が作成した私の NSObject です
/////.h
#import <Foundation/Foundation.h>
@interface alerts : NSObject {
}
- (void)pleaseRegisterDevice;
@end
/////.m
#import "alerts.h"
#import "instaCode1_3AppDelegate.h"
#import "RegisterDeviceViewController.h"
@implementation alerts
//use this alert when phone falls out of sync
- (void)pleaseRegisterDevice {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Please Register Device"
message:@"click OK to register"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert autorelease];
[alert show];
}
//Catch pleaseRegisterDevice method
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
NSString *buttonTitle=[alertView buttonTitleAtIndex:buttonIndex];
if ([buttonTitle isEqualToString:@"OK"]) {
NSLog(@"msg from alertView method");
//open new wndow
RegisterDeviceViewController *regViewController = [[RegisterDeviceViewController alloc] init];
//Push it onto the top pf the navigation controller's stack
**[[self navigationController] pushViewController:regViewController animated:YES];**
}
else {
NSLog(@"was not able to push view");
}
}
- (void)dealloc {
[super dealloc];
}
@end
「アラート」が -navigationController に応答しない可能性があるという警告が表示されるコード行を太字にしました
どんな助けでも大歓迎です。