6 Replies - 3568 Views - Last Post: 23 August 2011 - 10:32 PM

#1 thephpdev  Icon User is offline

  • D.I.C Head

Reputation: 9
  • View blog
  • Posts: 59
  • Joined: 01-July 11

iPhone SDK Error Help

Posted 06 August 2011 - 09:23 PM

Hello all, very new to iOS programming and I've run into problem after problem. I'm not sure what's wrong and what to fix so I came here. Here's the error:
GNU gdb 6.3.50-20050815 (Apple version gdb-1518) (Sat Feb 12 02:56:02 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "--host=x86_64-apple-darwin --target=arm-apple-darwin".tty /dev/ttys001
target remote-mobile /tmp/.XcodeGDBRemote-41902-34
Switching to remote-macosx protocol
mem 0x1000 0x3fffffff cache
mem 0x40000000 0xffffffff none
mem 0x00000000 0x0fff none
[Switching to process 11779 thread 0x0]
[Switching to process 11779 thread 0x0]
sharedlibrary apply-load-rules all
2011-08-06 23:19:27.709 Summer Miles[795:707] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIApplication 0x154a70> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key miles.'
*** Call stack at first throw:
(
	0   CoreFoundation                      0x330d364f __exceptionPreprocess + 114
	1   libobjc.A.dylib                     0x33592c5d objc_exception_throw + 24
	2   CoreFoundation                      0x330d33cd -[NSException dealloc] + 0
	3   Foundation                          0x3146eedb -[NSObject(NSKeyValueCoding) setValue:forUndefinedKey:] + 182
	4   Foundation                          0x314279cb _NSSetUsingKeyValueSetter + 90
	5   Foundation                          0x31427217 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 194
	6   Foundation                          0x3140942f -[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 130
	7   UIKit                               0x320bb8df -[UIRuntimeOutletConnection connect] + 66
	8   CoreFoundation                      0x3306bd7b -[NSObject(NSObject) performSelector:] + 18
	9   CoreFoundation                      0x3306b99d -[NSArray makeObjectsPerformSelector:] + 388
	10  UIKit                               0x320ba847 -[UINib instantiateWithOwner:options:] + 586
	11  UIKit                               0x320bbe09 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 92
	12  UIKit                               0x31ee64cd -[UIApplication _loadMainNibFile] + 96
	13  UIKit                               0x31ee0b09 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 180
	14  UIKit                               0x31eb57d7 -[UIApplication handleEvent:withNewEvent:] + 1114
	15  UIKit                               0x31eb5215 -[UIApplication sendEvent:] + 44
	16  UIKit                               0x31eb4c53 _UIApplicationHandleEvent + 5090
	17  GraphicsServices                    0x325c0e77 PurpleEventCallback + 666
	18  CoreFoundation                      0x330aaa97 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 26
	19  CoreFoundation                      0x330ac83f __CFRunLoopDoSource1 + 166
	20  CoreFoundation                      0x330ad60d __CFRunLoopRun + 520
	21  CoreFoundation                      0x3303dec3 CFRunLoopRunSpecific + 230
	22  CoreFoundation                      0x3303ddcb CFRunLoopRunInMode + 58
	23  UIKit                               0x31edfd49 -[UIApplication _run] + 372
	24  UIKit                               0x31edd807 UIApplicationMain + 670
	25  Summer Miles                        0x00002403 main + 82
	26  Summer Miles                        0x000023ac start + 40
)
terminate called after throwing an instance of 'NSException'
kill
Current language:  auto; currently objective-c
quit
Program ended with exit code: 0


Now Here's Summer_MilesViewController.m

//
//  Summer_MilesViewController.m
//  Summer Miles
//
//  Created by Josh Larson on 8/6/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "Summer_MilesViewController.h"

@implementation Summer_MilesViewController

/*
    For Adding Miles on to the current total this summer
*/ 
- (IBAction)milesAdd:(id)sender
{
    miles.text = @"Hello";                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  }



- (void)dealloc
{
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
    [super viewDidLoad];
}

- (void)loadView
{
    UIView *view = [[UIView alloc] init];
    self.view = view;
    [view release];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end


And Summer_MilesViewController.h

//
//  Summer_MilesViewController.h
//  Summer Miles
//
//  Created by Josh Larson on 8/6/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface Summer_MilesViewController : UIViewController {
    IBOutlet UITextField *miles;
    IBOutlet UILabel *total;
}

- (IBAction)milesAdd:(id)sender;

@end


Any help would be greatly appreciated!

This post has been edited by thephpdev: 06 August 2011 - 09:25 PM


Is This A Good Question/Topic? 0
  • +

Replies To: iPhone SDK Error Help

#2 shintetsu_80  Icon User is offline

  • D.I.C Head

Reputation: 31
  • View blog
  • Posts: 105
  • Joined: 01-July 08

Re: iPhone SDK Error Help

Posted 06 August 2011 - 11:24 PM

It's been a while since I've done Objective-C but based on the error I think you need to define your member variables as properties in your .h file. How you define your properties, the (nonatomic, retain) stuff, will depend on your needs. You may also want to add the @synthesize miles; @synthesize total; stuff to your implementation file. If you're not sure what that does just google it.


//
//  Summer_MilesViewController.h
//  Summer Miles
//
//  Created by Josh Larson on 8/6/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface Summer_MilesViewController : UIViewController {
    IBOutlet UITextField *miles;
    IBOutlet UILabel *total;
}

@property (nonatomic, retain) IBOutlet UITextField *miles;
@property (nonatomic, retain) IBOutlet UILabel *total;

- (IBAction)milesAdd:(id)sender;

@end


Was This Post Helpful? 0
  • +
  • -

#3 thephpdev  Icon User is offline

  • D.I.C Head

Reputation: 9
  • View blog
  • Posts: 59
  • Joined: 01-July 11

Re: iPhone SDK Error Help

Posted 07 August 2011 - 10:16 AM

Okay, the problem really occurs when I link the miles and total to the UI. I added the stuff you said and got this error with gdb:

*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIApplication 0x4b1a830> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key miles.'


Was This Post Helpful? 0
  • +
  • -

#4 shintetsu_80  Icon User is offline

  • D.I.C Head

Reputation: 31
  • View blog
  • Posts: 105
  • Joined: 01-July 08

Re: iPhone SDK Error Help

Posted 07 August 2011 - 01:50 PM

Here's two articles that point out the same problem and the solution. I don't see your init method so this should fix your problem.

link 1

link 2

This post has been edited by shintetsu_80: 07 August 2011 - 01:50 PM

Was This Post Helpful? 0
  • +
  • -

#5 thephpdev  Icon User is offline

  • D.I.C Head

Reputation: 9
  • View blog
  • Posts: 59
  • Joined: 01-July 11

Re: iPhone SDK Error Help

Posted 07 August 2011 - 03:23 PM

When I linked the things I made sure to set the class to SummerMilesViewController, which seemed to be the solution with both the articles you gave.
Was This Post Helpful? 0
  • +
  • -

#6 shintetsu_80  Icon User is offline

  • D.I.C Head

Reputation: 31
  • View blog
  • Posts: 105
  • Joined: 01-July 08

Re: iPhone SDK Error Help

Posted 10 August 2011 - 08:23 PM

It's been awhile since I've done some serious iOS programming so I cracked open a new test project. There's been some changes but I was able to copy your code and get it to compile. It looks like you might have a stale pointer have your tried doing a 'clean build'? If that doesn't work I would create a new project and try again. You haven't added much so I would make sure you can compile a new project without making any changes.
Was This Post Helpful? 0
  • +
  • -

#7 thephpdev  Icon User is offline

  • D.I.C Head

Reputation: 9
  • View blog
  • Posts: 59
  • Joined: 01-July 11

Re: iPhone SDK Error Help

Posted 23 August 2011 - 10:32 PM

Well I now get these outputs:
mem 0x1000 0x3fffffff cache
mem 0x40000000 0xffffffff none
mem 0x00000000 0x0fff none


And this popup on my mac:
Title: Error Starting Executable 'Summer Miles'
Description: putpkt: write failed: Broken pipe
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1