我遇到此问题会导致应用崩溃: 应用程序启动时,当我添加新视图以使用两个按钮处理2个uiimages时,问题就开始了
gameApp[5963:1756169] -[announceViewController xCJSONDidBeginLoadingJSONData]: unrecognized selector sent to instance 0x7faa01504d50
2014-11-03 09:16:01.386 gameApp[5963:1756169] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[announceViewController xCJSONDidBeginLoadingJSONData]: unrecognized selector sent to instance 0x7faa01504d50'
*** First throw call stack:
(
0 CoreFoundation 0x0000000107fe9f35 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000107c82bb7 objc_exception_throw + 45
2 CoreFoundation 0x0000000107ff104d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x0000000107f4908f ___forwarding___ + 495
4 CoreFoundation 0x0000000107f48e18 _CF_forwarding_prep_0 + 120
5 gameApp 0x0000000103d75462 -[XCJSONLoader startLoadFrom:] + 66
6 gameApp 0x0000000103d75de3 -[announceViewController setUpJSON] + 259
7 gameApp 0x0000000103d75c99 -[announceViewController viewDidLoad] + 73
8 UIKit 0x0000000106402a90 -[UIViewController loadViewIfRequired] + 738
9 UIKit 0x0000000106402c8e -[UIViewController view] + 27
10 UIKit 0x0000000106321ca9 -[UIWindow addRootViewControllerViewIfPossible] + 58
11 UIKit 0x0000000106322041 -[UIWindow _setHidden:forced:] + 247
12 UIKit 0x000000010632e72c -[UIWindow makeKeyAndVisible] + 42
13 UIKit 0x00000001062d9061 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 2628
14 UIKit 0x00000001062dbd2c -[UIApplication _runWithMainScene:transitionContext:completion:] + 1350
15 UIKit 0x00000001062dabf2 -[UIApplication workspaceDidEndTransaction:] + 179
16 FrontBoardServices 0x000000010dfa62a3 __31-[FBSSerialQueue performAsync:]_block_invoke + 16
17 CoreFoundation 0x0000000107f1f53c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
18 CoreFoundation 0x0000000107f15285 __CFRunLoopDoBlocks + 341
19 CoreFoundation 0x0000000107f15045 __CFRunLoopRun + 2389
20 CoreFoundation 0x0000000107f14486 CFRunLoopRunSpecific + 470
21 UIKit 0x00000001062da669 -[UIApplication _run] + 413
22 UIKit 0x00000001062dd420 UIApplicationMain + 1282
23 gameApp 0x0000000103d78913 main + 115
24 libdyld.dylib 0x0000000108c17145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
这是h文件:
#import <UIKit/UIKit.h>
#import "XCJSONLoader.h"
@interface announceViewController : UIViewController <XCJSONLoaderDelegate>
@property (strong,nonatomic) XCJSONLoader *jsonLoader;
@property (weak, nonatomic) IBOutlet UIImageView *anImageView;
@property (weak, nonatomic) IBOutlet UIImageView *spImageView;
- (IBAction)anButton:(id)sender;
- (IBAction)spButton:(id)sender;
@end
这是.m文件
@interface announceViewController () {
NSMutableArray *JSONData;
}
@end
@implementation announceViewController
@synthesize jsonLoader,anImageView,spImageView;
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
[self setUpJSON];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
- (void) setUpJSON
{
jsonLoader = [[XCJSONLoader alloc] init];
[jsonLoader setDelegate:self];
NSString *JSONLink = [NSString stringWithFormat:@"http://ya-techno.com/gameApp/anData.php"]; // Your URL goes here
[jsonLoader startLoadFrom:JSONLink];
}
- (void)xCJSONDidFinishLoadingJSONData
{
JSONData = [jsonLoader getJSONData];
}
- (IBAction)anButton:(id)sender {
JSONData = [jsonLoader getJSONData];
NSString *anButtonString = [NSString stringWithFormat:@"%@", [[JSONData objectAtIndex:0] objectForKey:@"anButton"]];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:anButtonString]];
}
- (IBAction)spButton:(id)sender {
}
@end
我找不到这个问题。任何帮助
答案 0 :(得分:0)
阅读错误。它表示您尚未实施xCJSONDidBeginLoadingJSONData
方法。你还没有。您确实拥有xCJSONDidFinishLoadingJSONData
方法,但没有xCJSONDidBeginLoadingJSONData
方法。
将xCJSONDidBeginLoadingJSONData
方法添加到announceViewController
课程以解决问题。
BTW - 标准命名约定规定类名应使用大写字母。方法和变量名以小写字母开头。