iPhone- Error With Spritekit Game - ios

I'm making a app using Apple's Spritekit framework. My app has multiple view controllers and everything works fine. However, I tried to make a scene that I would load in one of my viewcontrollers, but that did not work. I get no errors at all: it just does not work. Everything works except when I try to load my scene, everything crashes. Also, I was thinking, could my problem be that I have already added a view and put labels and buttons, etc... on that view before I load my scene? To elaborate, could the problem be that I have already added uiimages, etc... to the view using interface builder before I loaded my scene programmatically? Any help would be great. Here is my code for the view controller where I call my scene:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
SKView * skView = (SKView *)self.view;
// Create and configure the scene.
SKScene * scene = [MyScene sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
// Present the scene.
[skView presentScene:scene];
[super viewDidLoad];
// Do any additional setup after loading the view.
}
And here is my code for the actual scene:
-(id)initWithSize:(CGSize)size {
if (self = [super initWithSize:size]) {
/* Setup your scene here */
SKSpriteNode *mainTurrentSprite = [SKSpriteNode spriteNodeWithImageNamed:#"mainTurrent.png"];
mainTurrentSprite.position = CGPointMake(self.view.center.x, 0);
[self addChild:mainTurrentSprite];
}
return self;
}
And here is my crash/error log :
2014-07-22 14:32:34.783 Doodle Defense[6713:60b] -[UIView presentScene:]: unrecognized selector sent to instance 0x9a32630
2014-07-22 14:32:34.786 Doodle Defense[6713:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView presentScene:]: unrecognized selector sent to instance 0x9a32630'
*** First throw call stack:
(
0 CoreFoundation 0x019231e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x0168e8e5 objc_exception_throw + 44
2 CoreFoundation 0x019c0243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x0191350b ___forwarding___ + 1019
4 CoreFoundation 0x019130ee _CF_forwarding_prep_0 + 14
5 Doodle Defense 0x000020b1 -[GameViewController viewDidLoad] + 337
6 UIKit 0x0034b33d -[UIViewController loadViewIfRequired] + 696
7 UIKit 0x0034b5d9 -[UIViewController view] + 35
8 UIKit 0x0035af89 -[UIViewController shouldAutorotate] + 36
9 UIKit 0x0035b2d1 -[UIViewController _preferredInterfaceOrientationForPresentationInWindow:fromInterfaceOrientation:] + 297
10 UIKit 0x005f93d5 -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:animation:] + 2330
11 UIKit 0x003575d5 -[UIViewController presentViewController:withTransition:completion:] + 6538
12 UIKit 0x00357aef -[UIViewController presentViewController:animated:completion:] + 130
13 UIKit 0x00357b2f -[UIViewController presentModalViewController:animated:] + 56
14 UIKit 0x007a1e00 -[UIStoryboardModalSegue perform] + 271
15 UIKit 0x00790f0c -[UIStoryboardSegueTemplate _perform:] + 174
16 UIKit 0x00790f87 -[UIStoryboardSegueTemplate perform:] + 115
17 libobjc.A.dylib 0x016a0880 -[NSObject performSelector:withObject:withObject:] + 77
18 UIKit 0x0022e3b9 -[UIApplication sendAction:to:from:forEvent:] + 108
19 UIKit 0x0022e345 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
20 UIKit 0x0032fbd1 -[UIControl sendAction:to:forEvent:] + 66
21 UIKit 0x0032ffc6 -[UIControl _sendActionsForEvents:withEvent:] + 577
22 UIKit 0x0032f243 -[UIControl touchesEnded:withEvent:] + 641
23 UIKit 0x0026dddd -[UIWindow _sendTouchesForEvent:] + 852
24 UIKit 0x0026e9d1 -[UIWindow sendEvent:] + 1117
25 UIKit 0x002405f2 -[UIApplication sendEvent:] + 242
26 UIKit 0x0022a353 _UIApplicationHandleEventQueue + 11455
27 CoreFoundation 0x018ac77f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
28 CoreFoundation 0x018ac10b __CFRunLoopDoSources0 + 235
29 CoreFoundation 0x018c91ae __CFRunLoopRun + 910
30 CoreFoundation 0x018c89d3 CFRunLoopRunSpecific + 467
31 CoreFoundation 0x018c87eb CFRunLoopRunInMode + 123
32 GraphicsServices 0x039035ee GSEventRunModal + 192
33 GraphicsServices 0x0390342b GSEventRun + 104
34 UIKit 0x0022cf9b UIApplicationMain + 1225
35 Doodle Defense 0x00002add main + 141
36 libdyld.dylib 0x01f56701 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Related

Navigation one view controller to another getting

I want navigate viewController to TargetViewController but I'm getting following error:
2016-05-11 15:47:27.182 Sum of Numbers[2882:209790] *** Terminating
app due to uncaught exception 'NSUnknownKeyException', reason:
'[ setValue:forUndefinedKey:]:
this class is not key value coding-compliant for the key bttn.'
*** First throw call stack: ( 0 CoreFoundation 0x00000001016f9f45 __exceptionPreprocess + 165 1 libobjc.A.dylib
0x0000000101173deb objc_exception_throw + 48 2 CoreFoundation
0x00000001016f9b89 -[NSException raise] + 9 3 Foundation
0x0000000100d40a6b -[NSObject(NSKeyValueCoding) setValue:forKey:] +
288 4 UIKit 0x0000000101c3104c
-[UIViewController setValue:forKey:] + 88 5 UIKit 0x0000000101e5ea71 -[UIRuntimeOutletConnection connect] + 109 6
CoreFoundation 0x000000010163aa80 -[NSArray
makeObjectsPerformSelector:] + 224 7 UIKit
0x0000000101e5d454 -[UINib instantiateWithOwner:options:] + 1864 8
UIKit 0x0000000101c37c16
-[UIViewController _loadViewFromNibNamed:bundle:] + 381 9 UIKit 0x0000000101c38542 -[UIViewController loadView] + 178 10 UIKit
0x0000000101c388a0 -[UIViewController loadViewIfRequired] + 138 11
UIKit 0x0000000101c39013
-[UIViewController view] + 27 12 UIKit 0x00000001023db7e7 -[_UIFullscreenPresentationController
_setPresentedViewController:] + 87 13 UIKit 0x0000000101c08dde -[UIPresentationController
initWithPresentedViewController:presentingViewController:] + 133 14
UIKit 0x0000000101c4b9ba
-[UIViewController _presentViewController:withAnimationController:completion:] + 4004 15 UIKit 0x0000000101c4ec5c
-[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 489 16 UIKit 0x0000000101c4e76b
-[UIViewController presentViewController:animated:completion:] + 179 17 Sum of Numbers 0x0000000100c756f8
-[ViewController Sum:] + 120 18 UIKit 0x0000000101aa7e91 -[UIApplication sendAction:to:from:forEvent:] + 92
19 UIKit 0x0000000101c134d8
-[UIControl sendAction:to:forEvent:] + 67 20 UIKit 0x0000000101c137a4 -[UIControl _sendActionsForEvents:withEvent:] + 311
21 UIKit 0x0000000101c128d4
-[UIControl touchesEnded:withEvent:] + 601 22 UIKit 0x0000000101b15ed1 -[UIWindow _sendTouchesForEvent:] + 835 23 UIKit
0x0000000101b16c06 -[UIWindow sendEvent:] + 865 24 UIKit
0x0000000101ac62fa -[UIApplication sendEvent:] + 263 25 UIKit
0x0000000101aa0abf _UIApplicationHandleEventQueue + 6844 26
CoreFoundation 0x0000000101626011
__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 27 CoreFoundation 0x000000010161bf3c
__CFRunLoopDoSources0 + 556 28 CoreFoundation 0x000000010161b3f3 __CFRunLoopRun + 867 29 CoreFoundation
0x000000010161ae08 CFRunLoopRunSpecific + 488 30 GraphicsServices
0x0000000104e95ad2 GSEventRunModal + 161 31 UIKit
0x0000000101aa630d UIApplicationMain + 171 32 Sum of Numbers
0x0000000100c75aaf main + 111 33 libdyld.dylib
0x0000000103e1d92d start + 1 ) libc++abi.dylib: terminating with
uncaught exception of type NSException (lldb)
My viewController.m
#interface ViewController ()
#end
#implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)Sum:(id)sender {
TargetViewController *add = [[TargetViewController alloc]
initWithNibName:#"TargetViewController123" bundle:nil];
// TargetViewController *membr = [[TargetViewController alloc] initWithNibName:#"TargetViewController123"];
[self presentViewController:add animated:YES completion:nil];
}
#end
I don't know where I get the error. Please help
Your error is described here:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key bttn.
This means that something is trying to call a property bttn on a class that doesn't have a property with this name. This often happens if you have connected an IBOutlet in your view controller, and then deleted it in the code but forgot to remove the outlet reference from your element in Interface Builder.

Crash on focus UITextField

I am working on an iOS app, but for some reason all of a sudden my login page is not working anymore. All of the UIElements seem to be working fine except for the UITextField I use for the username (Password textField is working fine).
The login screen is very basic, it has a one viewcontroller and the username textfield has one outlet in that viewcontroller.
I don't do anything with the textfield when it focuses.
It happens on iOS8 on the physical iPad 2, and on the iPhone 4s emulator.
What I have tried to do:
Re-install the app
Re-ad the textField
Re-connect the Outlet
Revert my storyboard to a working version
I found some other answers, but none of them seem to have a conclusive answer.
Exception:
2015-03-24 11:13:53.695 App[43084:866627] -[__NSCFString objectAtIndex:]: unrecognized selector sent to instance 0x7ae5f920
2015-03-24 11:13:53.726 App[43084:866627] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString objectAtIndex:]: unrecognized selector sent to instance 0x7ae5f920'
*** First throw call stack:
(
0 CoreFoundation 0x00def466 __exceptionPreprocess + 182
1 libobjc.A.dylib 0x006d7a97 objc_exception_throw + 44
2 CoreFoundation 0x00df72c5 -[NSObject(NSObject) doesNotRecognizeSelector:] + 277
3 CoreFoundation 0x00d3fbc7 ___forwarding___ + 1047
4 CoreFoundation 0x00d3f78e _CF_forwarding_prep_0 + 14
5 CoreFoundation 0x00cc531c CFArrayGetValueAtIndex + 188
6 CoreFoundation 0x00d601ed CFStringTokenizerCreate + 749
7 UIKit 0x01c377ce __91-[_UITextInputControllerTokenizer _getClosestTokenRangeForPosition:granularity:downstream:]_block_invoke44 + 264
8 UIFoundation 0x0439e9d3 -[NSTextStorage coordinateReading:] + 51
9 UIKit 0x01c37459 -[_UITextInputControllerTokenizer _getClosestTokenRangeForPosition:granularity:downstream:] + 276
10 UIKit 0x018ba567 -[UITextInputStringTokenizer positionFromPosition:toBoundary:inDirection:] + 93
11 UIKit 0x018bad9d -[TIDocumentState(UITextInputAdditions) _contextBeforePosition:inDocument:] + 81
12 UIKit 0x018baef3 -[TIDocumentState(UITextInputAdditions) initWithDocument:] + 125
13 UIKit 0x018ba95f +[TIDocumentState(UITextInputAdditions) documentStateOfDocument:] + 63
14 UIKit 0x015fad7b -[UIKeyboardImpl syncDocumentStateToInputDelegateWithExecutionContext:] + 298
15 UIKit 0x015fb787 -[UIKeyboardImpl updateForChangedSelectionWithExecutionContext:] + 326
16 UIKit 0x015f57b6 __36-[UIKeyboardImpl setDelegate:force:]_block_invoke + 43
17 UIKit 0x01c384b2 -[UIKeyboardTaskQueue continueExecutionOnMainThread] + 404
18 UIKit 0x01c38b6f -[UIKeyboardTaskQueue addTask:] + 144
19 UIKit 0x015f5783 -[UIKeyboardImpl setDelegate:force:] + 2450
20 UIKit 0x015f4dec -[UIKeyboardImpl setDelegate:] + 60
21 UIKit 0x01928fe5 -[UIPeripheralHost(UIKitInternal) _reloadInputViewsForResponder:] + 1096
22 UIKit 0x01570687 -[UIResponder(UIResponderInputViewAdditions) reloadInputViews] + 316
23 UIKit 0x0156f6ec -[UIResponder becomeFirstResponder] + 562
24 UIKit 0x01435ba0 -[UIView(Hierarchy) becomeFirstResponder] + 114
25 UIKit 0x01c04607 -[UITextField becomeFirstResponder] + 51
26 UIKit 0x018051bf -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) setFirstResponderIfNecessary] + 200
27 UIKit 0x018077e6 -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) oneFingerTap:] + 2762
28 UIKit 0x017fb057 _UIGestureRecognizerSendActions + 327
29 UIKit 0x017f98d4 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 561
30 UIKit 0x017fb91d -[UIGestureRecognizer _delayedUpdateGesture] + 60
31 UIKit 0x017ff29a ___UIGestureRecognizerUpdate_block_invoke661 + 57
32 UIKit 0x017ff15d _UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks + 317
33 UIKit 0x017f3066 _UIGestureRecognizerUpdate + 3720
34 UIKit 0x0140ac5b -[UIWindow _sendGesturesForEvent:] + 1356
35 UIKit 0x0140babf -[UIWindow sendEvent:] + 769
36 UIKit 0x013d0bb1 -[UIApplication sendEvent:] + 242
37 UIKit 0x013e0bf6 _UIApplicationHandleEventFromQueueEvent + 21066
38 UIKit 0x013b4bc7 _UIApplicationHandleEventQueue + 2300
39 CoreFoundation 0x00d1298f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
40 CoreFoundation 0x00d0849d __CFRunLoopDoSources0 + 253
41 CoreFoundation 0x00d079f8 __CFRunLoopRun + 952
42 CoreFoundation 0x00d0737b CFRunLoopRunSpecific + 443
43 CoreFoundation 0x00d071ab CFRunLoopRunInMode + 123
44 GraphicsServices 0x04e182c1 GSEventRunModal + 192
45 GraphicsServices 0x04e180fe GSEventRun + 104
46 UIKit 0x013b89b6 UIApplicationMain + 1526
47 App 0x0005ffbd main + 141
48 libdyld.dylib 0x0296dac9 start + 1
49 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Viewcontroller:
#import "LoginViewController.h"
#implementation LoginViewController
UserManager *usermanager;
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (IBAction)cancelLogin:(id)sender {
[self dismissViewControllerAnimated:true completion:nil];
}
- (IBAction)login:(id)sender {
[loginIndicator startAnimating];
LoginHandler *loginhandler = [[LoginHandler alloc]initWithUsername:usernameField.text
password:passwordField.text
beta:betaSwitch.isOn
view:self];
[loginhandler loginUser];
}
-(void)resetFields{
usernameField.text = #"";
passwordField.text = #"";
[loginIndicator stopAnimating];
}
#end
Viewcontroller.h
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "LoginHandler.h"
#interface LoginViewController : UIViewController{
__weak IBOutlet UITextField *usernameField;
__weak IBOutlet UITextField *passwordField;
__weak IBOutlet UIActivityIndicatorView *loginIndicator;
__weak IBOutlet UISwitch *betaSwitch;
__weak IBOutlet UINavigationBar *navigationBar;
}
-(void)resetFields;
#end
An exception breakpoint gives this line:
2015-03-24 11:43:41.338 App[323:15867] -[__NSCFString objectAtIndex:]: unrecognized selector sent to instance 0x15653690
Can anyone else help me?
Thanks
I seem to have found an answer, it had something to do with my constraints for some reason. I cleared the constraints and re-added them and somehow it is working again.

Adding CollectionView programmatically

I'm attempting to add a CollectionView to my application with images. So I have setup one cell in the xib file and added an imageview, gave the cell identifier "Cell" for now and set it's delegate and datasource to the file's owner.
The issue I am having right now is that the application crashes whenever I enter the screen with that CollectionView.
2014-02-12 10:26:46.429 CollectionApp[509:a0b] *** Assertion failure in -[CollectionViewController loadView], /SourceCache/UIKit_Sim/UIKit-2903.23/UICollectionViewController.m:166
2014-02-12 10:26:46.510 CollectionApp[509:a0b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UICollectionViewController loadView] loaded the "34q-Sl-gDP-view-cX9-PP-w1h" nib but didn't get a UICollectionView.'
*** First throw call stack:
(
0 CoreFoundation 0x0191b5e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x0169e8b6 objc_exception_throw + 44
2 CoreFoundation 0x0191b448 +[NSException raise:format:arguments:] + 136
3 Foundation 0x0127efee -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
4 UIKit 0x008eaec3 -[UICollectionViewController loadView] + 582
5 UIKit 0x003c90ae -[UIViewController loadViewIfRequired] + 78
6 UIKit 0x003c95b4 -[UIViewController view] + 35
7 UIKit 0x004003ae -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 407
8 UIKit 0x003ffbd2 -[UITabBarController transitionFromViewController:toViewController:] + 63
9 UIKit 0x003fbfbb -[UITabBarController _setSelectedViewController:] + 279
10 UIKit 0x003fbe9c -[UITabBarController setSelectedViewController:] + 180
11 UIKit 0x003fface -[UITabBarController _tabBarItemClicked:] + 312
12 libobjc.A.dylib 0x016b0874 -[NSObject performSelector:withObject:withObject:] + 77
13 UIKit 0x002b70c2 -[UIApplication sendAction:to:from:forEvent:] + 108
14 UIKit 0x002b704e -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
15 UIKit 0x00565659 -[UITabBar _sendAction:withEvent:] + 479
16 libobjc.A.dylib 0x016b081f -[NSObject performSelector:withObject:] + 70
17 UIKit 0x002b70c2 -[UIApplication sendAction:to:from:forEvent:] + 108
18 UIKit 0x002b704e -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
19 UIKit 0x003af0c1 -[UIControl sendAction:to:forEvent:] + 66
20 UIKit 0x003af484 -[UIControl _sendActionsForEvents:withEvent:] + 577
21 UIKit 0x003af0f6 -[UIControl sendActionsForControlEvents:] + 48
22 UIKit 0x00569f80 -[UITabBar(Static) _buttonUp:] + 123
23 libobjc.A.dylib 0x016b0874 -[NSObject performSelector:withObject:withObject:] + 77
24 UIKit 0x002b70c2 -[UIApplication sendAction:to:from:forEvent:] + 108
25 UIKit 0x002b704e -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
26 UIKit 0x003af0c1 -[UIControl sendAction:to:forEvent:] + 66
27 UIKit 0x003af484 -[UIControl _sendActionsForEvents:withEvent:] + 577
28 UIKit 0x003ae733 -[UIControl touchesEnded:withEvent:] + 641
29 UIKit 0x002f451d -[UIWindow _sendTouchesForEvent:] + 852
30 UIKit 0x002f5184 -[UIWindow sendEvent:] + 1232
31 UIKit 0x002c8e86 -[UIApplication sendEvent:] + 242
32 UIKit 0x002b318f _UIApplicationHandleEventQueue + 11421
33 CoreFoundation 0x018a483f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
34 CoreFoundation 0x018a41cb __CFRunLoopDoSources0 + 235
35 CoreFoundation 0x018c129e __CFRunLoopRun + 910
36 CoreFoundation 0x018c0ac3 CFRunLoopRunSpecific + 467
37 CoreFoundation 0x018c08db CFRunLoopRunInMode + 123
38 GraphicsServices 0x0359c9e2 GSEventRunModal + 192
39 GraphicsServices 0x0359c809 GSEventRun + 104
40 UIKit 0x002b5d3b UIApplicationMain + 1225
41 CollectionApp 0x0000ed9d main + 141
42 libdyld.dylib 0x01f57725 start + 0
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Here's my CollectionViewController.h
#import "CollectionViewController.h"
#interface CollectionViewController () {
NSArray * listImages;
}
#end
#implementation CollectionViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
listImages = [NSArray arrayWithObjects:#"7513-kirjatkuivumassa.jpg", #"kuppi.jpg", #"kuva1.jpg", #"juna-042.jpg", #"rautio-valamonruusut-helleaamuna-maalaus.jpg", #"pysähtynyt1.jpg", #"Screen-Shot-2013-02-20-at-21.07.38.jpg", #"sateenkaari.jpg", #"Screen-Shot-2013-02-21-at-17.04.22.jpg", #"moninaiset-e1391026376696.jpg", #"Tomperi+Metsä20111.jpg", #"3-shinot.jpg", #"Ulpukat.jpg", #"janne-e1391025808211.jpg", #"martikainen-240x240.jpg", #"takala-240x240.jpg", #"paanukallokaarme1.jpg", #"käsityök-240x240.jpg", #"kuvis-004.jpg", #"Se-on-hieno-2012-tammi-105x28x223.jpg", nil];
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return listImages.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
static NSString *identifier = #"Cell";
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
UIImageView *listImageView = (UIImageView *)[cell viewWithTag:100];
listImageView.image = [UIImage imageNamed:[listImages objectAtIndex:indexPath.row]];
return cell;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#end
Please note that I am a complete noob when it comes to coding with Objective C. I'm currently attempting to study it.
All I had to do was to change
#interface CollectionViewController : UICollectionViewController
To
#interface CollectionViewController : UIViewController
Now there's no errors and everything works as intended.
You need register your xib cell to your UICollectionView on -(void)viewDidLoad of your view Controller.
[_tableView registerNib:[UINib nibWithNibName:#"nibName"
bundle:nil]
forCellReuseIdentifier:#"cellIdentifer"];

Crash attempting to set delegate of textfield

I have a lot of textfields and what I am trying to make them do is dismiss when the return key is used. In order for this to work you need to set the delegate of each textfield to self, like this [textfield setDelegate: self];. I have over 50 textfields in my project and in order to make it so they all dismiss I have to copy that line of code for each textfield. In the example below I used a for loop to try to shrink this down, but my project crashes and gives me this error when I try. Can someone tell me what im doing wrong and how i can fix this?
//.h
#interface InsertScheduleCGPS : UIViewController <UITextFieldDelegate>{
NSArray *Dayh;
IBOutlet UITextField *Day11;
}
#property(nonatomic, assign) id<UITextFieldDelegate> delegate;
#property (nonatomic,strong) NSArray *Dayh;
.
//.m
- (void)viewDidLoad
{
[super viewDidLoad];
Dayh = [NSArray arrayWithObjects:#"Day11", nil];
NSLog(#"euf");
for(int i=0; i<[self.Dayh count]; i++) {
NSLog(#"dd%#",[self.Dayh objectAtIndex:i]);
[[self.Dayh objectAtIndex:i] setDelegate: self];
}
- (BOOL)textFieldShouldReturn:(UITextField *)Day11 {
[[self view] endEditing:YES];
return NO;
}
ERROR:
2014-01-18 19:15:26.712 Swepple[64912:70b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString setDelegate:]: unrecognized selector sent to instance 0x144ec'
*** First throw call stack:
(
0 CoreFoundation 0x0183b5e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x015be8b6 objc_exception_throw + 44
2 CoreFoundation 0x018d8903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x0182b90b ___forwarding___ + 1019
4 CoreFoundation 0x0182b4ee _CF_forwarding_prep_0 + 14
5 Swepple 0x0000bbd6 -[InsertScheduleCGPS viewDidLoad] + 4262
6 UIKit 0x00440318 -[UIViewController loadViewIfRequired] + 696
7 UIKit 0x004405b4 -[UIViewController view] + 35
8 UIKit 0x0044f361 -[UIViewController viewControllerForRotation] + 63
9 UIKit 0x00446f00 -[UIViewController _visibleView] + 84
10 UIKit 0x006d511a -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:animation:] + 5199
11 UIKit 0x0044c0fc -[UIViewController presentViewController:withTransition:completion:] + 6433
12 UIKit 0x0044c61f -[UIViewController presentViewController:animated:completion:] + 130
13 UIKit 0x0044c65f -[UIViewController presentModalViewController:animated:] + 56
14 UIKit 0x00870e16 -[UIStoryboardModalSegue perform] + 271
15 UIKit 0x0086107e -[UIStoryboardSegueTemplate _perform:] + 174
16 UIKit 0x00442280 -[UIViewController performSegueWithIdentifier:sender:] + 72
17 Swepple 0x000052d4 -[SecondViewController insert:] + 244
18 libobjc.A.dylib 0x015d0874 -[NSObject performSelector:withObject:withObject:] + 77
19 UIKit 0x0032e0c2 -[UIApplication sendAction:to:from:forEvent:] + 108
20 UIKit 0x0032e04e -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
21 UIKit 0x004260c1 -[UIControl sendAction:to:forEvent:] + 66
22 UIKit 0x00426484 -[UIControl _sendActionsForEvents:withEvent:] + 577
23 UIKit 0x00425733 -[UIControl touchesEnded:withEvent:] + 641
24 UIKit 0x0036b51d -[UIWindow _sendTouchesForEvent:] + 852
25 UIKit 0x0036c184 -[UIWindow sendEvent:] + 1232
26 UIKit 0x0033fe86 -[UIApplication sendEvent:] + 242
27 UIKit 0x0032a18f _UIApplicationHandleEventQueue + 11421
28 CoreFoundation 0x017c483f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
29 CoreFoundation 0x017c41cb __CFRunLoopDoSources0 + 235
30 CoreFoundation 0x017e129e __CFRunLoopRun + 910
31 CoreFoundation 0x017e0ac3 CFRunLoopRunSpecific + 467
32 CoreFoundation 0x017e08db CFRunLoopRunInMode + 123
33 GraphicsServices 0x037e09e2 GSEventRunModal + 192
34 GraphicsServices 0x037e0809 GSEventRun + 104
35 UIKit 0x0032cd3b UIApplicationMain + 1225
36 Swepple 0x0000e04d main + 141
37 libdyld.dylib 0x01d7c70d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
You probably meant
Dayh = [NSArray arrayWithObjects:Day11, nil];
At present, Dayh is an array containing the string "Day11", not the text field.

[<UIView 0x89bfd40> setValue:forUndefinedKey:]

Another problem that is causing my build to succeed, then terminate. As follows:
Error:
2013-09-30 20:21:23.708 The Solver[2566:a0b] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIView 0x89bfd40> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key welcomeBeta.'
*** First throw call stack:
(
0 CoreFoundation 0x023615e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x014bf8b6 objc_exception_throw + 44
2 CoreFoundation 0x023f16a1 -[NSException raise] + 17
3 Foundation 0x00f73c2e -[NSObject(NSKeyValueCoding) setValue:forUndefinedKey:] + 282
4 Foundation 0x00edff3b _NSSetUsingKeyValueSetter + 88
5 Foundation 0x00edf493 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 267
6 UIKit 0x0008f97b -[UIView(CALayerDelegate) setValue:forKey:] + 168
7 Foundation 0x00f4194a -[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 412
8 UIKit 0x002c6cd5 -[UIRuntimeOutletConnection connect] + 106
9 libobjc.A.dylib 0x014d17d2 -[NSObject performSelector:] + 62
10 CoreFoundation 0x0235cb6a -[NSArray makeObjectsPerformSelector:] + 314
11 UIKit 0x002c582e -[UINib instantiateWithOwner:options:] + 1417
12 UIKit 0x00137c95 -[UIViewController _loadViewFromNibNamed:bundle:] + 280
13 UIKit 0x0013843d -[UIViewController loadView] + 302
14 UIKit 0x0013873e -[UIViewController loadViewIfRequired] + 78
15 UIKit 0x00138c44 -[UIViewController view] + 35
16 UIKit 0x000615ad -[UIWindow addRootViewControllerViewIfPossible] + 66
17 UIKit 0x00061947 -[UIWindow _setHidden:forced:] + 312
18 UIKit 0x00061bdd -[UIWindow _orderFrontWithoutMakingKey] + 49
19 UIKit 0x0006c44a -[UIWindow makeKeyAndVisible] + 65
20 UIKit 0x0001f8e0 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1851
21 UIKit 0x00023fb8 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
22 UIKit 0x0003842c -[UIApplication handleEvent:withNewEvent:] + 3447
23 UIKit 0x00038999 -[UIApplication sendEvent:] + 85
24 UIKit 0x00025c35 _UIApplicationHandleEvent + 736
25 GraphicsServices 0x022bf2eb _PurpleEventCallback + 776
26 GraphicsServices 0x022bedf6 PurpleEventCallback + 46
27 CoreFoundation 0x022dcdd5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
28 CoreFoundation 0x022dcb0b __CFRunLoopDoSource1 + 523
29 CoreFoundation 0x023077ec __CFRunLoopRun + 2156
30 CoreFoundation 0x02306b33 CFRunLoopRunSpecific + 467
31 CoreFoundation 0x0230694b CFRunLoopRunInMode + 123
32 UIKit 0x000236ed -[UIApplication _run] + 840
33 UIKit 0x0002594b UIApplicationMain + 1225
34 The Solver 0x000033dd main + 141
35 libdyld.dylib 0x059a5725 start + 0
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Code for UIControllerView with welcomeBeta (Button)
WelcomeUI.h:
#import <UIKit/UIKit.h>
#interface WelcomeUI : UIViewController
#property (weak, nonatomic) IBOutlet UIButton *welcomeStart;
#property (weak, nonatomic) IBOutlet UIButton *welcomeBeta;
#end
WelcomeUI.m:
#import "WelcomeUI.h"
#interface WelcomeUI ()
#end
#implementation WelcomeUI
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#end
Please let me know where I'm going wrong. Also explain in detail as I'm new to objective-c and Xcode.

Resources