Note that there are some explanatory texts on larger screens.

plurals
  1. POIOS - NSUnknownKeyException
    primarykey
    data
    text
    <p>I am struggling with an IOS app i literally just started. I followed this guide to the letter im sure</p> <p><a href="http://www.appcoda.com/how-to-get-current-location-iphone-user/" rel="nofollow">http://www.appcoda.com/how-to-get-current-location-iphone-user/</a></p> <p>However in the main method i get the following error;</p> <blockquote> <p>2013-12-04 20:28:55.591 MyLocationDemo[20391:c07] <strong>* Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key getLocation.' *</strong> First throw call stack: (0x1850012 0x116ce7e 0x18d8fb1 0xc18e41 0xb9a5f8 0xb9a0e7 0xbc4b58 0x2ce019 0x1180663 0x184b45a 0x2ccb1c 0x1917e7 0x191dc8 0x191ff8 0x192232 0xe13d5 0xe176f 0xe1905 0xea917 0xae96c 0xaf94b 0xc0cb5 0xc1beb 0xb3698 0x17abdf9 0x17abad0 0x17c5bf5 0x17c5962 0x17f6bb6 0x17f5f44 0x17f5e1b 0xaf17a 0xb0ffc 0x204d 0x1f75) libc++abi.dylib: terminate called throwing an exception</p> </blockquote> <p>Does anyone know roughly what might be wrong with my code? The files I have modified are </p> <pre><code>// // main.m // MyLocationDemo // #import &lt;UIKit/UIKit.h&gt; #import "MyLocationAppDelegate.h" #import "MyLocationViewController.h" int main(int argc, char *argv[]) { @autoreleasepool { return UIApplicationMain(argc, argv, nil, NSStringFromClass([MyLocationAppDelegate class])); } } // // MyLocationViewController.h // MyLocationDemo // #import &lt;UIKit/UIKit.h&gt; #import &lt;CoreLocation/CoreLocation.h&gt; @interface MyLocationViewController : UIViewController&lt;CLLocationManagerDelegate&gt; @property (weak, nonatomic) IBOutlet UILabel *latitudeLabel; @property (weak, nonatomic) IBOutlet UILabel *longitudeLabel; @property (weak, nonatomic) IBOutlet UILabel *addressLabel; - (IBAction)getLocation:(id)sender; @end </code></pre> <p>And this is where the main logic seems to be</p> <pre><code>// // MyLocationViewController.m // MyLocationDemo // // Created by Ricki Lambert on 04/12/2013. // Copyright (c) 2013 Ricki Lambert. All rights reserved. // #import "MyLocationViewController.h" @interface MyLocationViewController () @end @implementation MyLocationViewController CLLocationManager *locationManager; - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. locationManager = [[CLLocationManager alloc] init]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (IBAction)getLocation:(id)sender { locationManager.delegate = self; locationManager.desiredAccuracy = kCLLocationAccuracyBest; [locationManager startUpdatingLocation]; } #pragma mark - CLLocationManagerDelegate - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error { NSLog(@"didFailWithError: %@", error); UIAlertView *errorAlert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Failed to Get Your Location" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [errorAlert show]; } - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { NSLog(@"didUpdateToLocation: %@", newLocation); CLLocation *currentLocation = newLocation; if (currentLocation != nil) { _longitudeLabel.text = [NSString stringWithFormat:@"%.8f", currentLocation.coordinate.longitude]; _latitudeLabel.text = [NSString stringWithFormat:@"%.8f", currentLocation.coordinate.latitude]; } } @end </code></pre> <p><strong>EDIT:</strong> </p> <p>Added the following code </p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt; &lt;document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="2.0" toolsVersion="3084" systemVersion="12F37" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="2"&gt; &lt;dependencies&gt; &lt;plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="2083"/&gt; &lt;/dependencies&gt; &lt;scenes&gt; &lt;!--My Location View Controller--&gt; &lt;scene sceneID="5"&gt; &lt;objects&gt; &lt;viewController id="2" customClass="MyLocationViewController" sceneMemberID="viewController"&gt; &lt;view key="view" contentMode="scaleToFill" id="3"&gt; &lt;rect key="frame" x="0.0" y="20" width="320" height="548"/&gt; &lt;autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/&gt; &lt;subviews&gt; &lt;label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Lattitude" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="2NQ-NG-XNs"&gt; &lt;constraints&gt; &lt;constraint firstAttribute="width" constant="114" id="3lT-6l-45k"/&gt; &lt;constraint firstAttribute="height" constant="34" id="NHO-Yt-dF0"/&gt; &lt;/constraints&gt; &lt;fontDescription key="fontDescription" type="system" pointSize="17"/&gt; &lt;color key="textColor" cocoaTouchSystemColor="darkTextColor"/&gt; &lt;nil key="highlightedColor"/&gt; &lt;/label&gt; &lt;label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Longiude" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="RLl-n5-tOv"&gt; &lt;constraints&gt; &lt;constraint firstAttribute="width" constant="75" id="6AR-qh-Gnd"/&gt; &lt;constraint firstAttribute="height" constant="27" id="m84-iE-ZY7"/&gt; &lt;/constraints&gt; &lt;fontDescription key="fontDescription" type="system" pointSize="17"/&gt; &lt;color key="textColor" cocoaTouchSystemColor="darkTextColor"/&gt; &lt;nil key="highlightedColor"/&gt; &lt;/label&gt; &lt;label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Address" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="1kJ-EE-aHk"&gt; &lt;constraints&gt; &lt;constraint firstAttribute="height" constant="27" id="6U9-sr-UXJ"/&gt; &lt;/constraints&gt; &lt;fontDescription key="fontDescription" type="system" pointSize="17"/&gt; &lt;color key="textColor" cocoaTouchSystemColor="darkTextColor"/&gt; &lt;nil key="highlightedColor"/&gt; &lt;/label&gt; &lt;label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Lattitude goes here" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="fNS-Dr-1Vu"&gt; &lt;fontDescription key="fontDescription" type="system" pointSize="17"/&gt; &lt;color key="textColor" cocoaTouchSystemColor="darkTextColor"/&gt; &lt;nil key="highlightedColor"/&gt; &lt;/label&gt; &lt;label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Longitude goes here" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="NoA-nn-nJE"&gt; &lt;fontDescription key="fontDescription" type="system" pointSize="17"/&gt; &lt;color key="textColor" cocoaTouchSystemColor="darkTextColor"/&gt; &lt;nil key="highlightedColor"/&gt; &lt;/label&gt; &lt;label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Address goes here" lineBreakMode="tailTruncation" numberOfLines="4" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="158" translatesAutoresizingMaskIntoConstraints="NO" id="FRc-NM-7R7"&gt; &lt;constraints&gt; &lt;constraint firstAttribute="height" constant="110" id="Mxn-SQ-dDB"/&gt; &lt;constraint firstAttribute="width" constant="158" id="giI-DM-8Y6"/&gt; &lt;/constraints&gt; &lt;fontDescription key="fontDescription" type="system" pointSize="14"/&gt; &lt;color key="textColor" cocoaTouchSystemColor="darkTextColor"/&gt; &lt;nil key="highlightedColor"/&gt; &lt;/label&gt; &lt;button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="tGJ-fU-7T9"&gt; &lt;constraints&gt; &lt;constraint firstAttribute="width" constant="194" id="wCV-5v-wAp"/&gt; &lt;/constraints&gt; &lt;fontDescription key="fontDescription" type="boldSystem" pointSize="15"/&gt; &lt;state key="normal" title="Get Address"&gt; &lt;color key="titleColor" red="0.19607843459999999" green="0.30980393290000002" blue="0.52156865600000002" alpha="1" colorSpace="calibratedRGB"/&gt; &lt;color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/&gt; &lt;/state&gt; &lt;state key="highlighted"&gt; &lt;color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/&gt; &lt;/state&gt; &lt;connections&gt; &lt;action selector="getLocation:" destination="2" eventType="touchUpInside" id="4Gy-OZ-lTb"/&gt; &lt;/connections&gt; &lt;/button&gt; &lt;/subviews&gt; &lt;color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/&gt; &lt;constraints&gt; &lt;constraint firstAttribute="trailing" secondItem="FRc-NM-7R7" secondAttribute="trailing" constant="20" symbolic="YES" type="default" id="0Hn-nk-jah"/&gt; &lt;constraint firstItem="FRc-NM-7R7" firstAttribute="top" secondItem="3" secondAttribute="top" constant="177" id="2a9-5q-b4n"/&gt; &lt;constraint firstItem="NoA-nn-nJE" firstAttribute="top" secondItem="RLl-n5-tOv" secondAttribute="top" type="default" id="8xW-ST-2rJ"/&gt; &lt;constraint firstItem="RLl-n5-tOv" firstAttribute="leading" secondItem="2NQ-NG-XNs" secondAttribute="leading" type="default" id="9D0-0e-Dab"/&gt; &lt;constraint firstItem="1kJ-EE-aHk" firstAttribute="top" secondItem="3" secondAttribute="top" constant="174" id="Atx-uI-F5b"/&gt; &lt;constraint firstAttribute="bottom" secondItem="tGJ-fU-7T9" secondAttribute="bottom" constant="131" id="GmZ-gM-2LB"/&gt; &lt;constraint firstItem="1kJ-EE-aHk" firstAttribute="leading" secondItem="RLl-n5-tOv" secondAttribute="leading" type="default" id="Gyh-cL-XiN"/&gt; &lt;constraint firstItem="tGJ-fU-7T9" firstAttribute="centerX" secondItem="3" secondAttribute="centerX" type="default" id="Tb3-0Y-di7"/&gt; &lt;constraint firstItem="FRc-NM-7R7" firstAttribute="leading" secondItem="NoA-nn-nJE" secondAttribute="leading" type="default" id="U11-d2-DSe"/&gt; &lt;constraint firstItem="RLl-n5-tOv" firstAttribute="top" secondItem="3" secondAttribute="top" constant="104" id="VdS-si-Rf1"/&gt; &lt;constraint firstItem="fNS-Dr-1Vu" firstAttribute="top" secondItem="3" secondAttribute="top" constant="43" id="cM5-dt-7bh"/&gt; &lt;constraint firstItem="2NQ-NG-XNs" firstAttribute="top" secondItem="3" secondAttribute="top" constant="37" id="mV7-Ff-Uuy"/&gt; &lt;constraint firstItem="2NQ-NG-XNs" firstAttribute="leading" secondItem="3" secondAttribute="leading" constant="39" id="spa-RY-ZpM"/&gt; &lt;constraint firstItem="1kJ-EE-aHk" firstAttribute="trailing" secondItem="RLl-n5-tOv" secondAttribute="trailing" type="default" id="x03-z0-I5T"/&gt; &lt;constraint firstItem="NoA-nn-nJE" firstAttribute="leading" secondItem="fNS-Dr-1Vu" secondAttribute="leading" type="default" id="x1R-k4-2ns"/&gt; &lt;/constraints&gt; &lt;/view&gt; &lt;connections&gt; &lt;outlet property="addressLabel" destination="FRc-NM-7R7" id="oNw-qt-0yh"/&gt; &lt;outlet property="getLocation" destination="tGJ-fU-7T9" id="69B-gi-HDF"/&gt; &lt;outlet property="latitudeLabel" destination="fNS-Dr-1Vu" id="hTv-w4-7tN"/&gt; &lt;outlet property="longitudeLabel" destination="NoA-nn-nJE" id="OxD-hl-qRK"/&gt; &lt;/connections&gt; &lt;/viewController&gt; &lt;placeholder placeholderIdentifier="IBFirstResponder" id="4" sceneMemberID="firstResponder"/&gt; &lt;/objects&gt; &lt;/scene&gt; &lt;/scenes&gt; &lt;classes&gt; &lt;class className="MyLocationViewController" superclassName="UIViewController"&gt; &lt;source key="sourceIdentifier" type="project" relativePath="./Classes/MyLocationViewController.h"/&gt; &lt;relationships&gt; &lt;relationship kind="action" name="getLocation:"/&gt; &lt;relationship kind="outlet" name="addressLabel" candidateClass="UILabel"/&gt; &lt;relationship kind="outlet" name="getLocation" candidateClass="UIButton"/&gt; &lt;relationship kind="outlet" name="latitudeLabel" candidateClass="UILabel"/&gt; &lt;relationship kind="outlet" name="longitudeLabel" candidateClass="UILabel"/&gt; &lt;/relationships&gt; &lt;/class&gt; &lt;class className="NSLayoutConstraint" superclassName="NSObject"&gt; &lt;source key="sourceIdentifier" type="project" relativePath="./Classes/NSLayoutConstraint.h"/&gt; &lt;/class&gt; &lt;/classes&gt; &lt;simulatedMetricsContainer key="defaultSimulatedMetrics"&gt; &lt;simulatedStatusBarMetrics key="statusBar"/&gt; &lt;simulatedOrientationMetrics key="orientation"/&gt; &lt;simulatedScreenMetrics key="destination" type="retina4"/&gt; &lt;/simulatedMetricsContainer&gt; &lt;/document&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload