I'm following and online course and got stock because even by following the step (or maybe I missed some ? ) i get and error. I made several search on google and here but since i'm new to IOS development, even with answer from others, i can relate to my issue..
here is the error:
2015-06-12 23:03:17.477 Pirate Game[6511:1193126] -[RBTile setWeapon:]: unrecognized selector sent to instance 0x78830dc0
2015-06-12 23:03:17.481 Pirate Game[6511:1193126] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[RBTile setWeapon:]: unrecognized selector sent to instance 0x78830dc0'
*** First throw call stack:
(
0 CoreFoundation 0x00874746 __exceptionPreprocess + 182
1 libobjc.A.dylib 0x004fda97 objc_exception_throw + 44
2 CoreFoundation 0x0087c705 -[NSObject(NSObject) doesNotRecognizeSelector:] + 277
3 CoreFoundation 0x007c3287 ___forwarding___ + 1047
4 CoreFoundation 0x007c2e4e _CF_forwarding_prep_0 + 14
5 Pirate Game 0x00014a94 -[RBFactory tiles] + 388
6 Pirate Game 0x00011c6f -[ViewController viewDidLoad] + 143
7 UIKit 0x00d97da4 -[UIViewController loadViewIfRequired] + 771
8 UIKit 0x00d98095 -[UIViewController view] + 35
9 UIKit 0x00c89e85 -[UIWindow addRootViewControllerViewIfPossible] + 66
10 UIKit 0x00c8a34c -[UIWindow _setHidden:forced:] + 287
11 UIKit 0x00c8a648 -[UIWindow _orderFrontWithoutMakingKey] + 49
12 UIKit 0x00c989b6 -[UIWindow makeKeyAndVisible] + 80
13 UIKit 0x00c2ded8 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 3217
14 UIKit 0x00c31422 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1639
15 UIKit 0x00c4a93e __84-[UIApplication _handleApplicationActivationWithScene:transitionContext:completion:]_block_invoke + 59
16 UIKit 0x00c3004a -[UIApplication workspaceDidEndTransaction:] + 155
17 FrontBoardServices 0x031d6c9e __37-[FBSWorkspace clientEndTransaction:]_block_invoke_2 + 71
18 FrontBoardServices 0x031d672f __40-[FBSWorkspace _performDelegateCallOut:]_block_invoke + 54
19 FrontBoardServices 0x031e8d7c __31-[FBSSerialQueue performAsync:]_block_invoke_2 + 30
20 CoreFoundation 0x00796050 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 16
21 CoreFoundation 0x0078b963 __CFRunLoopDoBlocks + 195
22 CoreFoundation 0x0078b7bb __CFRunLoopRun + 2715
23 CoreFoundation 0x0078aa5b CFRunLoopRunSpecific + 443
24 CoreFoundation 0x0078a88b CFRunLoopRunInMode + 123
25 UIKit 0x00c2fa02 -[UIApplication _run] + 571
26 UIKit 0x00c33106 UIApplicationMain + 1526
27 Pirate Game 0x000148da main + 138
28 libdyld.dylib 0x02c00ac9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
So what i could understand from my search, is that i'm trying to send something that is not the same type. I have the same problem with all 3 custom class.
//
// RBFactory.m
// Pirate Game
//
// Created by Richard Berube on 2015-06-06.
// Copyright (c) 2015 Richard Berube. All rights reserved.
//
#import "RBFactory.h"
#import "RBTile.h"
#implementation RBFactory
-(NSArray *)tiles{
RBTile *tile1 = [[RBTile alloc] init];
tile1.story = #"Captain, we need a fearless leader such as you to undertake a voyage. You must stop the evil pirate Boss before he steals any more plunder. Would you like a blunted sword to get started?";
tile1.backgroundImage = [UIImage imageNamed:#"PirateStart.png"];
CCWeapon *bluntedSword = [[CCWeapon alloc]init];
bluntedSword.name = #"Blunted sword";
bluntedSword.damage = 12;
NSLog(#"%#", bluntedSword);
tile1.weapon = bluntedSword;
tile1.actionButtonName =#"Take the sword";
I tested with breakpoint and the crash occure
tile1.weapon = bluntedSword;
NSLog return:
2015-06-12 23:03:14.602 Pirate Game[6511:1193126] <CCWeapon: 0x786a6f50>
here is the tile class
//
// RBTile.h
// Pirate Game
//
// Created by Richard Berube on 2015-06-06.
// Copyright (c) 2015 Richard Berube. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "CCWeapon.h"
#import "CCArmor.h"
#interface RBTile : NSObject
#property (nonatomic, strong) NSString *story;
#property (strong, nonatomic) UIImage *backgroundImage;
#property (nonatomic, strong) NSString *actionButtonName;
#property (strong, nonatomic) CCWeapon *weapon;
#property (strong, nonatomic) CCArmor *armor;
#property (nonatomic) int healthEffect;
#end
The .m file is empty
//
// RBTile.m
// Pirate Game
//
// Created by Richard Berube on 2015-06-06.
// Copyright (c) 2015 Richard Berube. All rights reserved.
//
#import "RBTile.h"
#implementation RBTile
#end
And the last one is the custom class, one of them actualy, because all 3 are causing the same issue..
//
// CCWeapon.h
// Pirate Game
//
// Created by Richard Berube on 2015-06-10.
// Copyright (c) 2015 Richard Berube. All rights reserved.
//
#import <Foundation/Foundation.h>
#interface CCWeapon : NSObject
#property (strong,nonatomic) NSString *name;
#property (nonatomic) int damage;
#end
A little help would be really apreciated! i'm now stock since 2 days.. i could start over all the video (online course) but that won't teach me how to debug ..
Maybe the last usefull info could be that i used Xcode 6.3.1
THanks !
update 1 : The final project is this one
https://github.com/codecoalition/Pirate-Adventure-Assignment/tree/master/Pirate%20Adventure
my RBtile is the CCtile in the github project
update 2: here is my viewcontroler
//
// ViewController.m
// Pirate Game
//
// Created by Richard Berube on 2015-06-06.
// Copyright (c) 2015 Richard Berube. All rights reserved.
//
#import "ViewController.h"
#import "RBFactory.h"
#import "RBTile.h"
#interface ViewController ()
#end
#implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
RBFactory *factory = [[RBFactory alloc]init];
self.tiles = [factory tiles];
self.character = [factory character];
self.currentPoint = CGPointMake(0, 0);
[self updateTile];
[self updateButtons];
[self updateCharacterStatsForArmor:nil withWeapons:nil withHealthEffect:0];
}
-(void)updateTile{
RBTile *tileModel = [[self.tiles objectAtIndex:self.currentPoint.x] objectAtIndex:self.currentPoint.y];
self.storyLabel.text = tileModel.story;
self.backgroundImageView.image = tileModel.backgroundImage;
self.healthLabel.text = [NSString stringWithFormat:#"%i", self.character.health];
self.damageLabel.text = [NSString stringWithFormat:#"%i", self.character.damage];
self.armorLabel.text = self.character.armor.name;
self.weaponLabel.text = self.character.weapon.name;
[self.actionButton setTitle:tileModel.actionButtonName forState:UIControlStateNormal];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)actionButtonPressed:(UIButton *)sender {
RBTile *tile = [[self.tiles objectAtIndex:self.currentPoint.x] objectAtIndex:self.currentPoint.y];
[self updateCharacterStatsForArmor:tile.armor withWeapons:tile.weapon withHealthEffect:tile.healthEffect];
[self updateTile];
}
- (IBAction)northButtonPressed:(UIButton *)sender {
self.currentPoint = CGPointMake(self.currentPoint.x, self.currentPoint.y +1);
[self updateButtons];
[self updateTile];
}
- (IBAction)southButtonPressed:(UIButton *)sender {
self.currentPoint = CGPointMake(self.currentPoint.x, self.currentPoint.y -1);
[self updateButtons];
[self updateTile];
}
- (IBAction)eastButtonPressed:(UIButton *)sender {
self.currentPoint = CGPointMake(self.currentPoint.x + 1, self.currentPoint.y);
[self updateButtons];
[self updateTile];
}
- (IBAction)westButtonPressed:(UIButton *)sender {
self.currentPoint = CGPointMake(self.currentPoint.x - 1, self.currentPoint.y);
[self updateButtons];
[self updateTile];
}
- (IBAction)restartButtonPressed:(UIButton *)sender {
}
-(void)updateButtons{
self.westButton.hidden = [self tilesExistAtPoint:CGPointMake(self.currentPoint.x -1, self.currentPoint.y)];
self.eastButton.hidden = [self tilesExistAtPoint:CGPointMake(self.currentPoint.x+1, self.currentPoint.y)];
self.northButton.hidden = [self tilesExistAtPoint:CGPointMake(self.currentPoint.x, self.currentPoint.y+1)];
self.southButton.hidden = [self tilesExistAtPoint:CGPointMake(self.currentPoint.x, self.currentPoint.y-1)];
}
-(BOOL)tilesExistAtPoint:(CGPoint)point{
if (point.y >= 0 && point.x >=0 && point.x < [self.tiles count] && point.y < [[self.tiles objectAtIndex:point.x] count]) {
return NO;
}
else{
return YES;
}
}
-(void)updateCharacterStatsForArmor:(CCArmor *)armor withWeapons:(CCWeapon *)weapon withHealthEffect:(int)healtEffect{
if (armor != nil ) {
self.character.health = self.character.health - self.character.armor.health +armor.health;
self.character.armor = armor;
}
else if (weapon != nil){
self.character.damage = self.character.damage - self.character.weapon.damage + weapon.damage;
self.character.weapon = weapon;
}
else if (healtEffect != 0){
self.character.health = self.character.health + healtEffect;
}
else {
self.character.health = self.character.health + self.character.armor.health;
self.character.damage = self.character.damage + self.character.weapon.damage;
}
}
#end
Another update:
I was able to find with the breakpoint that some of my property are not showing up..
When in fact it should be like that:
So now i know that when i try to pass tile1.weapon = bluntedSword; it is not working because tile1.weapon do not exist. But if you look in my RBTile.h all my property are there..
I am following the same course, and my code is the same as yours, and it works. The Tile.m files is empty.
In recent Xcode versions, synthesize statements are not always necessary. Some rare cases, I think, still need them.
I think the reason you don't see the other properties in the debug window is because the code that creates them hasn't run yet.
Try commenting out the lines that related to bluntedSword and see if the other properties are set successfully, or if they also cause the app to crash.
Another thing to try, and I understand how silly it sounds, is to re-type the lines (not copy and paste) and related lines that are causing the problems. Sometimes this works, so it's worth trying.
Good luck!
The root of the issue is this
[RBTile setWeapon:]: unrecognized selector sent to instance 0x78830dc0
That is telling you that your RBTile.weapon property on the RBTile class does not have a setter. Please update your post with the .m file showing how you are creating the weapon property on the RBTile. Odds are you are declaring a getter and potentially forgetting the setter.
Your .m file is empty, which is causing the issue. The header file just defines a contract between an object using your class, and the implementation of the class in the .m file. You can think of it as a bridge of sorts between something using the class, and the actual implementation of the class.
At runtime, the game can't find an implementation of the property to work with, thus the reason why unrecognized selector is being thrown.
Related
I am trying to port an iOS app over to React Native.
In this iOS app, one of the functions that needs to be done is to integrate it with a PayPal library (which is currently deprecated - we want to move away from it at some point later this year, but do not have the resources to do so now).
All we're doing with this library is obtaining a unique code from PayPal - that requires a View Controller to pop up, accept client credentials and return a code giving access.
I am extremely new to Objective-C.
I've got this so far (note: I have not included all the methods/properties but can include any missing):
COMPLETE PaypalSdk.h and PaypalSdk.m are at the bottom now
I am basing this off of this library:
https://github.com/paypal/PayPal-iOS-SDK/blob/master/SampleApp/PayPal-iOS-SDK-Sample-App/ZZMainViewController.m
And this documentation:
https://github.com/paypal/PayPal-iOS-SDK/blob/master/docs/profile_sharing_mobile.md
However when trying what I am above, I get the following error:
How exactly should I resolve this? It seems to need a View Controller but I'm not totally sure how to launch one from React Native in this context.
All we're trying to get is the shared profile information.
Here is one of the stack traces:
callstack: (
0 CoreFoundation 0x00007fff23c7127e __exceptionPreprocess + 350
1 libobjc.A.dylib 0x00007fff513fbb20 objc_exception_throw + 48
2 UIKitCore 0x00007fff47a25b1a -[UIViewController _presentViewController:withAnimationController:completion:] + 5247
3 UIKitCore 0x00007fff47a2801b __63-[UIViewController _presentViewController:animated:completion:]_block_invoke + 98
4 UIKitCore 0x00007fff47a28533 -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 511
5 UIKitCore 0x00007fff47a27f79 -[UIViewController _presentViewController:animated:completion:] + 187
6 UIKitCore 0x00007fff47a281e0 -[UIViewController presentViewController:animated:completion:] + 150
7 myappname 0x000000010f92f8ac -[PaypalSdk getUserAuthorizationForProfileSharing] + 348
8 myappname 0x000000010f92fd99 -[PaypalSdk generateCode:] + 233
9 CoreFoundation 0x00007fff23c7820c __invoking___ + 140
10 CoreFoundation 0x00007fff23c753af -[NSInvocation invoke] + 319
11 CoreFoundation 0x00007fff23c75684 -[NSInvocation invokeWithTarget:] + 68
12 myappname 0x000000010f6e3902 -[RCTModuleMethod invokeWithBridge:module:arguments:] + 2658
13 myappname 0x000000010f6e7a37 _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicE + 791
14 myappname 0x000000010f6e7543 _ZZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEiENK3$_0clEv + 131
15 myappname 0x000000010f6e74b9 ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 25
16 libdispatch.dylib 0x0000000110caddd4 _dispatch_call_block_and_release + 12
17 libdispatch.dylib 0x0000000110caed48 _dispatch_client_callout + 8
18 libdispatch.dylib 0x0000000110cb55ef _dispatch_lane_serial_drain + 788
19 libdispatch.dylib 0x0000000110cb617f _dispatch_lane_invoke + 422
20 libdispatch.dylib 0x0000000110cc1a4e _dispatch_workloop_worker_thread + 719
21 libsystem_pthread.dylib 0x00007fff5246371b _pthread_wqthread + 290
22 libsystem_pthread.dylib 0x00007fff5246357b start_wqthread + 15
)
Here is my complete PayPalSdk.m file:
#import <PayPal-iOS-SDK/PayPalMobile.h>
#import <PayPal-iOS-SDK/PayPalConfiguration.h>
#import <PayPal-iOS-SDK/PayPalOAuthScopes.h>
#import <PayPal-iOS-SDK/PayPalProfileSharingViewController.h>
#import <QuartzCore/QuartzCore.h>
#import "PaypalSdk.h"
#interface PaypalSdk ()
#property(nonatomic, strong, readwrite) IBOutlet UIButton *payNowButton;
#property(nonatomic, strong, readwrite) IBOutlet UIButton *payFutureButton;
#property(nonatomic, strong, readwrite) IBOutlet UIView *successView;
#property(nonatomic, strong, readwrite) PayPalConfiguration *payPalConfig;
#end
#implementation PaypalSdk
#define kPayPalEnvironment PayPalEnvironmentProduction
//int *REQUEST_CODE_PROFILE_SHARING = 3;
- (void)viewDidLoad {
[super viewDidLoad];
self.title = #"Pinyada PayPal";
// Set up payPalConfig
self.payPalConfig = [[PayPalConfiguration alloc] init];
self.payPalConfig.acceptCreditCards = NO;
self.payPalConfig.merchantName = #"Pinyada PayPal";
self.payPalConfig.merchantPrivacyPolicyURL = [NSURL URLWithString:#"https://www.paypal.com/webapps/mpp/ua/privacy-full"];
self.payPalConfig.merchantUserAgreementURL = [NSURL URLWithString:#"https://www.paypal.com/webapps/mpp/ua/useragreement-full"];
NSLog(#"PayPal iOS SDK version: %#", [PayPalMobile libraryVersion]);
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
#warning "Enter your credentials"
[PayPalMobile initializeWithClientIdsForEnvironments:#{PayPalEnvironmentProduction : #"PayPalProductionID",
PayPalEnvironmentSandbox : #"YOUR_CLIENT_ID_FOR_SANDBOX"}];
return YES;
}
/*- (void)generateCode:()code {
NSLog(#"Test");
}*/
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
// Start out working with the mock environment. When you are ready, switch to PayPalEnvironmentProduction.
[PayPalMobile preconnectWithEnvironment:PayPalEnvironmentProduction];
}
- (IBAction)getUserAuthorizationForProfileSharing:(id)sender {
NSSet *scopeValues = [NSSet setWithArray:#[kPayPalOAuth2ScopeOpenId, kPayPalOAuth2ScopeEmail, kPayPalOAuth2ScopeAddress, kPayPalOAuth2ScopePhone]];
PayPalProfileSharingViewController *profileSharingPaymentViewController = [[PayPalProfileSharingViewController alloc] initWithScopeValues:scopeValues configuration:self.payPalConfig delegate:self];
[self presentViewController:profileSharingPaymentViewController animated:YES completion:nil];
}
- (IBAction)obtainConsent {
// Choose whichever scope-values apply in your case. See `PayPalOAuthScopes.h` for a complete list of available scope-values.
NSSet *scopeValues = [NSSet setWithArray:#[kPayPalOAuth2ScopeOpenId, kPayPalOAuth2ScopeEmail, kPayPalOAuth2ScopeAddress, kPayPalOAuth2ScopePhone]];
PayPalProfileSharingViewController *psViewController;
NSLog(#"PS VIEW CONTROLLER");
NSLog(psViewController);
psViewController = [[PayPalProfileSharingViewController alloc] initWithScopeValues:scopeValues
configuration:self.payPalConfig
delegate:self];
// Access the root view controller
UIViewController *rootviewcontroller= [UIApplication sharedApplication].keyWindow.rootViewController;
// Present the PayPalProfileSharingViewController
[ rootviewcontroller presentViewController:psViewController animated:YES completion:nil];
}
- (void)userDidCancelPayPalProfileSharingViewController:(PayPalProfileSharingViewController *)profileSharingViewController {
// User cancelled login. Dismiss the PayPalProfileSharingViewController, breathe deeply.
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)payPalProfileSharingViewController:(PayPalProfileSharingViewController *)profileSharingViewController
userDidLogInWithAuthorization:(NSDictionary *)profileSharingAuthorization {
// The user has successfully logged into PayPal, and has consented to profile sharing.
NSLog(#"REACT NATIVE ENV test");
// Be sure to dismiss the PayPalProfileSharingViewController.
[self dismissViewControllerAnimated:YES completion:nil];
}
RCT_EXPORT_MODULE()
RCT_EXPORT_METHOD(generateCode: (RCTResponseSenderBlock)callback) {
[PayPalMobile initializeWithClientIdsForEnvironments:#{PayPalEnvironmentProduction : #"PayPalProductionID",
PayPalEnvironmentSandbox : #"YOUR_CLIENT_ID_FOR_SANDBOX"}];
[self obtainConsent];
NSLog(#"REACT NATIVE ENV test");
//code = #"this is a test!";
// TODO: Implement some actually useful functionality
callback(#[[NSNull null], #"test"]);
}
#end
And here is my complete PaypalSdk.h file:
#import "RCTBridgeModule.h"
#import "PayPalMobile.h"
#interface PaypalSdk : UIViewController <RCTBridgeModule, PayPalProfileSharingDelegate>
#property(nonatomic, strong, readwrite) NSString *environment;
#property(nonatomic, strong, readwrite) NSString *resultText;
#property(nonatomic, strong) UIWindow *window;
#property(nonatomic, strong) UIViewController *rootViewController;
#end
So you need to access the root view controller and then call presentViewController on the same. Something like below should do the trick:
- (IBAction)obtainConsent {
// Choose whichever scope-values apply in your case. See `PayPalOAuthScopes.h` for a complete list of available scope-values.
NSSet *scopeValues = [NSSet setWithArray:#[kPayPalOAuth2ScopeOpenId, kPayPalOAuth2ScopeEmail, kPayPalOAuth2ScopeAddress, kPayPalOAuth2ScopePhone]];
PayPalProfileSharingViewController *psViewController;
psViewController = [[PayPalProfileSharingViewController alloc] initWithScopeValues:scopeValues
configuration:self.payPalConfig
delegate:self];
// Access the root view controller
UIViewController *rootviewcontroller= [UIApplication sharedApplication].keyWindow.rootViewController;
// Present the PayPalProfileSharingViewController
[ rootviewcontroller presentViewController:psViewController animated:YES completion:nil];
}
I haven’t tried this so please check and let me know if this works. Otherwise find a view on which you can present the view controller.
Updating the answer based on the interaction with the OP:
For this to make it work, the view related methods had to be overriden with RCT methods and they need to be called before calling the generatecode RCT method. This along with root view controller seems to fix the issue.
Do not use that SDK. It is very old and deprecated.
If you need a native SDK to process payments with PayPal, you can use express checkout via Braintree. It also requires a web service of your own: https://developer.paypal.com/docs/accept-payments/express-checkout/ec-braintree-sdk/get-started/
I'm new to iOS and I'm writing my first application using wit.ai SDK (following this guide https://wit.ai/docs/ios/3.1.1/quickstart).
I can run my app and send a command (that I'll find in my wit.ai inbox) but then the app craches.
Here is my code:
AppDelegate.h
#import <UIKit/UIKit.h>
#interface AppDelegate : UIResponder <UIApplicationDelegate>
#property (strong, nonatomic) UIWindow *window;
#end
AppDelegate.m
#import "AppDelegate.h"
#import <Wit/Wit.h>
#interface AppDelegate ()
#end
#implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[Wit sharedInstance].accessToken = #"ASW7RE57SOSZLTNBAM6HQ53QAWXSROOI";
[Wit sharedInstance].detectSpeechStop = WITVadConfigDetectSpeechStop;
// Override point for customization after application launch.
return YES;
}
ViewController.h
#import <UIKit/UIKit.h>
#import <Wit/Wit.h>
#interface ViewController : UIViewController <WitDelegate>
#end
ViewController.m
#import "ViewController.h"
#interface ViewController ()
#end
#implementation ViewController {
UILabel *labelView;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// set the WitDelegate object
[Wit sharedInstance].delegate = self;
// create the button
CGRect screen = [UIScreen mainScreen].bounds;
CGFloat w = 100;
CGRect rect = CGRectMake(screen.size.width/2 - w/2, 60, w, 100);
WITMicButton* witButton = [[WITMicButton alloc] initWithFrame:rect];
[self.view addSubview:witButton];
// create the label
labelView = [[UILabel alloc] initWithFrame:CGRectMake(0, 200, screen.size.width, 50)];
labelView.textAlignment = NSTextAlignmentCenter;
[self.view addSubview:labelView];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)witDidGraspIntent:(NSArray *)outcomes entities:(NSDictionary *)entities body:(NSString *)body error:(NSError*)e {
if (e) {
NSLog(#"[Wit] error: %#", [e localizedDescription]);
return;
}
NSDictionary *firstOutcome = [outcomes objectAtIndex:0];
NSString *intent = [firstOutcome objectForKey:#"intent"];
labelView.text = [NSString stringWithFormat:#"intent = %#", intent];
[self.view addSubview:labelView];
}
#end
Here are the errors I get:
2015-01-12 22:24:21.419 FirstApp[11199:775307] WITVad init
2015-01-12 22:24:27.789 FirstApp[11199:775513] Error when enqueuing buffer from callback: -66632
2015-01-12 22:24:27.790 FirstApp[11199:775513] Error when enqueuing buffer from callback: -66632
2015-01-12 22:24:27.790 FirstApp[11199:775513] Error when enqueuing buffer from callback: -66632
2015-01-12 22:24:27.790 FirstApp[11199:775513] Error when enqueuing buffer from callback: -66632
2015-01-12 22:24:27.790 FirstApp[11199:775513] Error when enqueuing buffer from callback: -66632
2015-01-12 22:24:36.442 FirstApp[11199:775307] -[NSCFString objectAtIndex:]: unrecognized selector sent to instance 0x7f8da0c60c30
2015-01-12 22:24:36.755 FirstApp[11199:775307] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString objectAtIndex:]: unrecognized selector sent to instance 0x7f8da0c60c30'
*** First throw call stack:
(
0 CoreFoundation 0x0000000105bd0f35 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010548fbb7 objc_exception_throw + 45
2 CoreFoundation 0x0000000105bd804d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x0000000105b3027c ___forwarding_ + 988
4 CoreFoundation 0x0000000105b2fe18 _CF_forwarding_prep_0 + 120
5 FirstApp 0x00000001034778bd -[ViewController witDidGraspIntent:entities:body:error:] + 253
6 FirstApp 0x000000010347a705 -[Wit processMessage:] + 535
7 FirstApp 0x000000010347a3a2 -[Wit gotResponse:error:] + 67
8 FirstApp 0x000000010347a3f3 -[Wit gotResponse:error:customData:] + 62
9 FirstApp 0x0000000103478549 -[WITRecordingSession gotResponse:error:] + 196
10 FirstApp 0x000000010347b726 39-[WITUploader startRequestWithContext:]_block_invoke + 708
11 CFNetwork 0x0000000106781935 __67+[NSURLConnection sendAsynchronousRequest:queue:completionHandler:]_block_invoke_2 + 155
12 Foundation 0x000000010360201f __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK + 7
13 Foundation 0x0000000103541db2 -[NSBlockOperation main] + 98
14 Foundation 0x0000000103524384 -[NSOperationInternal _start:] + 645
15 Foundation 0x0000000103523f93 __NSOQSchedule_f + 184
16 libdispatch.dylib 0x0000000106eec7f4 _dispatch_client_callout + 8
17 libdispatch.dylib 0x0000000106ed58fb _dispatch_main_queue_callback_4CF + 949
18 CoreFoundation 0x0000000105b38fe9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 9
19 CoreFoundation 0x0000000105afbeeb __CFRunLoopRun + 2043
20 CoreFoundation 0x0000000105afb486 CFRunLoopRunSpecific + 470
21 GraphicsServices 0x0000000107f739f0 GSEventRunModal + 161
22 UIKit 0x00000001039d2420 UIApplicationMain + 1282
23 FirstApp 0x0000000103477e53 main + 115
24 libdyld.dylib 0x0000000106f21145 start + 1
25 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Thanks for your help.
I have got this problem cause the app crash:
The probelm start when the app launch when I add the new view to handle 2 uiimages with two buttons
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
and here is the h file :
#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
and this is the .m file
#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
I could not find the problem for this one. Any help
Read the error. It says you haven't implemented the xCJSONDidBeginLoadingJSONData method. And you haven't. You do have the xCJSONDidFinishLoadingJSONData method but not the xCJSONDidBeginLoadingJSONData method.
Add the xCJSONDidBeginLoadingJSONData method to your announceViewController class to fix the problem.
BTW - standard naming conventions state that class names should being with uppercase letters. Method and variable names begin with lowercase letters.
So I'm new to iOS programming and I've run into a problem.
I created a new view controller, and clicked the checkmark to auto make a .xib file for it. In the xib file I put a label, that I want to fade in. So I tried linking it to my custom view controller, and keep crashing with 'this class is not key value coding-compliant for the key login1'. Login1 being the name of the UILabel I imported. Here's the header file for RootView:
#interface RootViewController : UIViewController {
PlayerStatViewController *playerStatViewController;
NSString *viewName;
}
#property (weak, nonatomic) IBOutlet UILabel *login1;
#property (nonatomic, retain) PlayerStatViewController *playerStatViewController;
#property (nonatomic, retain) NSString *viewName;
-(IBAction)switchPage:(id)sender:(NSString *)toSwitch;
-(void) animateButton;
#end
And the .m file:
#import "RootViewController.h"
#import "FileUtils.h"
#interface RootViewController ()
#end
#implementation RootViewController
#synthesize playerStatViewController;
#synthesize viewName;
#synthesize login1;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
}
self.viewName = #"Boot";
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
NSString* fpath = [NSString stringWithFormat:#"%#%#", getDefPath(), #"/config.txt"];
self.login1.text = loadfile(#"serverName", fpath);
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
-(IBAction)switchPage:(id)sender :(NSString *)toSwitch {
if([toSwitch isEqualToString:(#"PlayerStat")]) {
if(self.playerStatViewController == nil) {
PlayerStatViewController *playerStatView = [[PlayerStatViewController alloc]
initWithNibName:(#"PlayerStat") bundle:[NSBundle mainBundle]];
self.playerStatViewController = playerStatView;
}
[self.navigationController pushViewController:self.playerStatViewController animated:YES];
}else if([toSwitch isEqualToString:(#"Boot")]) {
[self.navigationController pushViewController:self animated:YES];
}
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self performSelector:#selector(animateButton) withObject:nil afterDelay:0.1f];
}
- (void)animateButton {
self.login1.alpha = 0;
[UIView animateWithDuration:0.5 delay:0 options:UIViewAnimationOptionCurveEaseIn
animations:^{ self.login1.alpha = 1;}
completion:nil];
}
#end
How I load the Xib (if it matters):
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
RootViewController *viewController = [[RootViewController alloc] initWithNibName:#"RootViewController" bundle:nil];
[self.window setRootViewController:viewController];
[window makeKeyAndVisible];
return YES;
}
Project being built for iPhone only.
In the Xib, yes the custom view controller is set as the file owner. There is no mispointing values (exclamation points in inspection manager).
edit:
crash log:
2014-08-06 06:02:12.887 TrinityApi[5761:60b] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIApplication 0x8c781d0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key login1.'
*** First throw call stack:
(
0 CoreFoundation 0x017ee1e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x0156d8e5 objc_exception_throw + 44
2 CoreFoundation 0x0187dfe1 -[NSException raise] + 17
3 Foundation 0x0122dd9e -[NSObject(NSKeyValueCoding) setValue:forUndefinedKey:] + 282
4 Foundation 0x0119a1d7 _NSSetUsingKeyValueSetter + 88
5 Foundation 0x01199731 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 267
6 Foundation 0x011fbb0a -[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 412
7 UIKit 0x004e41f4 -[UIRuntimeOutletConnection connect] + 106
8 libobjc.A.dylib 0x0157f7de -[NSObject performSelector:] + 62
9 CoreFoundation 0x017e976a -[NSArray makeObjectsPerformSelector:] + 314
10 UIKit 0x004e2d4d -[UINib instantiateWithOwner:options:] + 1417
11 UIKit 0x004e4ada -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 165
12 UIKit 0x0022d61b -[UIApplication _loadMainNibFileNamed:bundle:] + 58
13 UIKit 0x0022d949 -[UIApplication _loadMainInterfaceFile] + 245
14 UIKit 0x0022c54e -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 543
15 UIKit 0x00240f92 -[UIApplication handleEvent:withNewEvent:] + 3517
16 UIKit 0x00241555 -[UIApplication sendEvent:] + 85
17 UIKit 0x0022e250 _UIApplicationHandleEvent + 683
18 GraphicsServices 0x037e3f02 _PurpleEventCallback + 776
19 GraphicsServices 0x037e3a0d PurpleEventCallback + 46
20 CoreFoundation 0x01769ca5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
21 CoreFoundation 0x017699db __CFRunLoopDoSource1 + 523
22 CoreFoundation 0x0179468c __CFRunLoopRun + 2156
23 CoreFoundation 0x017939d3 CFRunLoopRunSpecific + 467
24 CoreFoundation 0x017937eb CFRunLoopRunInMode + 123
25 UIKit 0x0022bd9c -[UIApplication _run] + 840
26 UIKit 0x0022df9b UIApplicationMain + 1225
27 TrinityApi 0x00002a9d main + 141
28 libdyld.dylib 0x01e35701 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
EDIT: Just randomly started to work
"class is not key value coding-compliant " means You had assigned an outlet to our label at first and had connected it in our xib, but then you have deleted the outlet and the xib is still containing a reference to the outlet which is no longer present, You need to remove this reference from your xib.
Goto your XIB file and right click on Files Owner, you may find a label with a yellow mark on it, just remove the outlet to which its connected to, clean and run your program once again
This question already has answers here:
Xcode - How to fix 'NSUnknownKeyException', reason: … this class is not key value coding-compliant for the key X" error?
(79 answers)
Closed 7 years ago.
I am trying to compile and run a simple tutorial for an Objective C app using Interface Builder. I am using Xcode 4.0.2 and simulating on iOS (iPhone) 4.3
http://www.switchonthecode.com/tutorials/creating-your-first-iphone-application-with-interface-builder
When I build the project, it builds alright but once the app tries to run it crashes with:
int main(int argc, char *argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, #"SimpleUIAppDelegate");
[pool release];
return retVal;
}
I get the error on line 4: int retVal = UI... Thread 1: Program Received Signal "SIGABRT".
If the other files of this project need to be posted for clarity, I can do that.
Thanks!
Edit:
SimpleUIViewController.h:
#import <UIKit/UIKit.h>
#interface SimpleUIViewController : UIViewController <UITextFieldDelegate> {
UITextField *textInput;
UILabel *label;
NSString *name;
}
#property (nonatomic, retain) IBOutlet UITextField *textInput;
#property (nonatomic, retain) IBOutlet UILabel *label;
#property (nonatomic, copy) NSString *name;
- (IBAction)changeGreeting:(id)sender;
#end
SimpleUIViewController.m:
#import "SimpleUIViewController.h"
#implementation SimpleUIViewController
#synthesize textInput;
#synthesize label;
#synthesize name;
- (IBAction)changeGreeting:(id)sender {
self.name = textInput.text;
NSString *nameString = name;
if([nameString length] == 0) {
nameString = #"Inigo Montoya";
}
NSString *greeting = [[NSString alloc]
initWithFormat:#"Hello, my name is %#!", nameString];
label.text = greeting;
[greeting release];
}
- (BOOL)textFieldShouldReturn:(UITextField *)theTextField {
if(theTextField == textInput) {
[textInput resignFirstResponder];
}
return YES;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Release anything that's not essential, such as cached data
}
- (void)dealloc {
[textInput release];
[label release];
[name release];
[super dealloc];
}
#end
Error message:
This GDB was configured as "x86_64-apple-darwin".Attaching to process 2668.
2011-06-09 11:20:21.662 InterfaceBuilder[2668:207] Unknown class InterfaceBuilderAppDelegate_iPhone in Interface Builder file.
2011-06-09 11:20:21.666 InterfaceBuilder[2668:207] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIApplication 0x4b1a900> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key textInput.'
*** Call stack at first throw:
(
0 CoreFoundation 0x00dc25a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x00f16313 objc_exception_throw + 44
2 CoreFoundation 0x00dc24e1 -[NSException raise] + 17
3 Foundation 0x00794677 _NSSetUsingKeyValueSetter + 135
4 Foundation 0x007945e5 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 285
5 UIKit 0x0021030c -[UIRuntimeOutletConnection connect] + 112
6 CoreFoundation 0x00d388cf -[NSArray makeObjectsPerformSelector:] + 239
7 UIKit 0x0020ed23 -[UINib instantiateWithOwner:options:] + 1041
8 UIKit 0x00210ab7 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168
9 UIKit 0x0001617a -[UIApplication _loadMainNibFile] + 172
10 UIKit 0x00016cf4 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 291
11 UIKit 0x00021617 -[UIApplication handleEvent:withNewEvent:] + 1533
12 UIKit 0x00019abf -[UIApplication sendEvent:] + 71
13 UIKit 0x0001ef2e _UIApplicationHandleEvent + 7576
14 GraphicsServices 0x00ffb992 PurpleEventCallback + 1550
15 CoreFoundation 0x00da3944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
16 CoreFoundation 0x00d03cf7 __CFRunLoopDoSource1 + 215
17 CoreFoundation 0x00d00f83 __CFRunLoopRun + 979
18 CoreFoundation 0x00d00840 CFRunLoopRunSpecific + 208
19 CoreFoundation 0x00d00761 CFRunLoopRunInMode + 97
20 UIKit 0x000167d2 -[UIApplication _run] + 623
21 UIKit 0x00022c93 UIApplicationMain + 1160
22 InterfaceBuilder 0x000027ff main + 127
23 InterfaceBuilder 0x00002775 start + 53
24 ??? 0x00000001 0x0 + 1
)
terminate called after throwing an instance of 'NSException'
sharedlibrary apply-load-rules all
Current language: auto; currently objective-c
(gdb)
Im new to obj-c, and have absolutely no idea what I'm looking at in regards to that error message. Any help?
You have an error in your NIB/XIB file.
It looks like you have previously attached an IBOutlet (textInput) and now the connection is broken. You should double check all connections in Interface Builder.
It's likely that you have set the type of 'File's Owner' incorrectly to UIViewController in your SimpleUIViewController's xib. Please set it to SimpleUIViewController in identity inspector pane.
Now I see it! Your crash report says:
Unknown class InterfaceBuilderAppDelegate_iPhone
So, it seems that you set your App Delegate in IB to this class, but this class is not available in your project. Check this. Either you misspelled the class name or you should add the relevant class to your project.
Highly likely, your text field is connected to this app delegate.
Have you connected your text field in Interface Builder to the SimpleUIViewController outlet?
Since it seems from the tutorial that you are not using MainWindow.xib, I would say that your project is missing running the proper delegate. Try making this change in your main:
int retVal = UIApplicationMain(argc, argv, nil, #"SimpleUIAppDelegate");
If my hypothesis is right, that should move your forward.
To fix it, load the XIB in Interface Builder, select the File Inspector tab, and uncheck Use autolayout. Alternatively, you can target iOS 6.0+-only devices and change the minimum target, if you absolutely must have autolayout.
NSLayoutConstraint SIGABRT on iPad
thread 1 program recived singal sigabrt
some times NSString value is goes to nill!
it may cause this while initialization of your application!