-1

I'm receiving an error while running my xcode project. My app always work, so I can't really see why this isn't working any more. Does anyone have an idea? I've found that it's caused due to an invalid method I'm calling. I can't seem to figure out where this mistake is located.. Anyone?

The error I get:

2014-02-25 11:52:06.784 Chemie Xpert - PSE[1381:70b] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIApplication 0x8d49be0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key view.'
*** First throw call stack:
(
    0   CoreFoundation                      0x023625e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x014bc8b6 objc_exception_throw + 44
    2   CoreFoundation                      0x023f26a1 -[NSException raise] + 17
    3   Foundation                          0x00f709ee -[NSObject(NSKeyValueCoding) setValue:forUndefinedKey:] + 282
    4   Foundation                          0x00edccfb _NSSetUsingKeyValueSetter + 88
    5   Foundation                          0x00edc253 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 267
    6   Foundation                          0x00f3e70a -[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 412
    7   UIKit                               0x002bfa15 -[UIRuntimeOutletConnection connect] + 106
    8   libobjc.A.dylib                     0x014ce7d2 -[NSObject performSelector:] + 62
    9   CoreFoundation                      0x0235db6a -[NSArray makeObjectsPerformSelector:] + 314
    10  UIKit                               0x002be56e -[UINib instantiateWithOwner:options:] + 1417
    11  UIKit                               0x002c02fb -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 165
    12  UIKit                               0x0001d3bb -[UIApplication _loadMainNibFileNamed:bundle:] + 58
    13  UIKit                               0x0001d6e9 -[UIApplication _loadMainInterfaceFile] + 245
    14  UIKit                               0x0001c28f -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 543
    15  UIKit                               0x0003087c -[UIApplication handleEvent:withNewEvent:] + 3447
    16  UIKit                               0x00030de9 -[UIApplication sendEvent:] + 85
    17  UIKit                               0x0001e025 _UIApplicationHandleEvent + 736
    18  GraphicsServices                    0x022c02f6 _PurpleEventCallback + 776
    19  GraphicsServices                    0x022bfe01 PurpleEventCallback + 46
    20  CoreFoundation                      0x022ddd65 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
    21  CoreFoundation                      0x022dda9b __CFRunLoopDoSource1 + 523
    22  CoreFoundation                      0x0230877c __CFRunLoopRun + 2156
    23  CoreFoundation                      0x02307ac3 CFRunLoopRunSpecific + 467
    24  CoreFoundation                      0x023078db CFRunLoopRunInMode + 123
    25  UIKit                               0x0001badd -[UIApplication _run] + 840
    26  UIKit                               0x0001dd3b UIApplicationMain + 1225
    27  Chemie Xpert - PSE                  0x0000247d main + 141
    28  libdyld.dylib                       0x0598d70d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

My code:

main.m:

#import <UIKit/UIKit.h>

#import "AppDelegate.h"

int main(int argc, char *argv[])
{
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
    }
}

ViewController.m:

#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
@synthesize webview;

- (void)viewDidLoad
{
    [super viewDidLoad];
    NSString *path = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html" inDirectory:@"localHTML"];
    NSURL *url = [NSURL fileURLWithPath:path];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [webview loadRequest:request];

    webview.scalesPageToFit = YES;
    webview.scrollView.bounces = NO;
    webview.scrollView.minimumZoomScale = 1;
    webview.scrollView.bouncesZoom = FALSE;

}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (BOOL)prefersStatusBarHidden
{
    return YES;
}
@end
Connor Pearson
  • 63,902
  • 28
  • 145
  • 142
Robbie
  • 75
  • 10
  • See also: http://stackoverflow.com/questions/3088059/this-class-is-not-key-value-coding-compliant-for-the-key – Amar Feb 25 '14 at 11:19
  • See also: http://stackoverflow.com/questions/5109309/this-class-is-not-key-value-coding-compliant-for-the-key-authview – Amar Feb 25 '14 at 11:19
  • can you show your viewCotnroller.h ? – Basheer_CAD Feb 25 '14 at 11:31
  • @Basheer_CAD my ViewController.h: ` #import @interface ViewController : UIViewController{ IBOutlet UIWebView *webview; } @property (nonatomic, retain) UIWebView *webview; @end` – Robbie Feb 26 '14 at 09:02
  • first, you can remove the redeclaration of web view in your interface, second to fix the issue temporarily you can add outlet in your .h file call it connect @Robbie – Basheer_CAD Feb 26 '14 at 09:20

2 Answers2

0

Maybe you deleted the UIView object from the NIB and replaced with the UIWebView. This is fine, but you should link the webView to the "view" property of the viewController in the xib file.

Ivaylo Slavov
  • 8,839
  • 12
  • 65
  • 108
Lolloz89
  • 2,809
  • 2
  • 26
  • 41
0

Is the webview set as an IBOutlet? That could be the cause.

Joey Clover
  • 756
  • 5
  • 14
  • Yes indeed, my ViewController.h: ` #import @interface ViewController : UIViewController{ IBOutlet UIWebView *webview; } @property (nonatomic, retain) UIWebView *webview; @end` – Robbie Feb 26 '14 at 08:59