setValue : forUndefinedKey :이 클래스는 키에 대해 키 값 코딩을 준수하지 않습니다.
이 질문에 이미 답변이 있습니다.
지원 티켓을보기 위해 로그인을 만들고 있습니다. 첫 번째보기는 티켓보기이며 로그인하지 않은 경우 로그인 화면으로 이동합니다. 그러나 나는 이것을 받는다 :
지원 [3209 : 18e03] * 포착되지 않은 예외 'NSUnknownKeyException'으로 인해 앱 종료 중, 이유 : '[setValue : forUndefinedKey :] :이 클래스는 LoginScreen 키에 대해 키 값 코딩을 준수하지 않습니다.' *
먼저 던져 호출 스택 : (0x1f17012 0x1634e7e 0x1f9ffb1 0x10e1711 0x1062ec8 0x10629b7 0x108d428 0x7990cc 0x1648663 0x1f1245a 0x797bcf 0x65ce37 0x65d418 0x65d648 0x65d882 0x669235 0x8683d2 0x6664f3 0x666777 0x6667b7 0x9d1fe2 0x9c3ad9 0x65e422 0x2b15 0x65f753 0x65fb2f 0x661286 0x65fe3f 0x592910 0x592895 0x5926e5 0x1edfafe 0x1edfa3d 0x1ebd7c2 0x1ebcf44 0x1ebce1b 0x22aa7e3 0x22aa668 0x57c65c 0x1f0d 0x1e35)의 libc + + abi.dylib : 종료는 예외 발생
LoginScreen.m의 코드는 다음과 같습니다.
#import "UIAlertView+error.h"
#import "LoginScreen.h"
#import "API.h"
#include <CommonCrypto/CommonDigest.h>
#define sayWhat @"REMOVEDFORSECURITY"
@implementation LoginScreen
-(void)viewDidLoad {
NSLog(@"Found me!");
[super viewDidLoad];
//focus on the username field /show keyboard
[fldUsername becomeFirstResponder];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
-(IBA
ction)btnLoginRegisterTapped:(UIButton*)sender {
if (fldUsername.text.length < 4 || fldPassword.text.length < 4){
[UIAlertView error:@"Enter username and password over 4 chars each."];
return;
}
//very basic encryption called "salting"
NSString* saltedPassword = [NSString stringWithFormat:@"%@%@", fldPassword.text, sayWhat];
//prep the hashed storage
NSString* hashedPassword = nil;
unsigned char hashedPasswordData[CC_SHA1_DIGEST_LENGTH];
//actually hash this
NSData *data = [saltedPassword dataUsingEncoding: NSUTF8StringEncoding];
if (CC_SHA1([data bytes], [data length], hashedPasswordData)){
hashedPassword = [[NSString alloc] initWithBytes:hashedPasswordData length:sizeof(hashedPasswordData) encoding:NSASCIIStringEncoding];
} else {
[UIAlertView error:@"Password can't be sent"];
return;
}
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
fldUsername.text, @"username",
hashedPassword, @"password", nil];
//here is the web call finally!
[[API sharedInstance] commandWithParams:params
onCompletion:^(NSDictionary *json){
//returned result
NSDictionary* res = [[json objectForKey:@"result"] objectAtIndex:0];
if([json objectForKey:@"error"]==nil && [[res objectForKey:@"userid"] intValue]> 0) {
//success
} else {
//error'
[UIAlertView error:[json objectForKey:@"error"]];
}
}];
}
@end
및 LoginScreen.h
#import <UIKit/UIKit.h>
@interface LoginScreen : UIViewController {
//the login form fields
IBOutlet UITextField* fldUsername;
IBOutlet UITextField* fldPassword;
}
//action for when either button is pressed
-(IBAction)btnLoginRegisterTapped:(id)sender;
@end
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="2.0" toolsVersion="2844" systemVersion="12C60" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="A8c-eR-geg">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="1930"/>
</dependencies>
<scenes>
<!--Tickets View - View Tickets-->
<scene sceneID="aIJ-Wx-2Yy">
<objects>
<viewController title="View Tickets" id="T0P-Bi-31w" customClass="TicketsView" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="4zZ-I2-ltX">
<rect key="frame" x="0.0" y="64" width="320" height="504"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="You Made It" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Fbu-Sr-Mgf">
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="Fbu-Sr-Mgf" firstAttribute="top" secondItem="4zZ-I2-ltX" secondAttribute="top" constant="138" id="QBp-qM-fKP"/>
<constraint firstItem="Fbu-Sr-Mgf" firstAttribute="leading" secondItem="4zZ-I2-ltX" secondAttribute="leading" constant="115" id="goO-5h-RZK"/>
</constraints>
</view>
<navigationItem key="navigationItem" id="vu4-JX-C3v"/>
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
<connections>
<segue destination="TOB-FA-Ss4" kind="modal" identifier="ShowLogin" id="dJH-ge-8CV"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="aSa-2G-5fx" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-518" y="-841"/>
</scene>
<!--Login Screen - Login-->
<scene sceneID="6iZ-QL-7ID">
<objects>
<viewController title="Login" id="TOB-FA-Ss4" customClass="LoginScreen" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="w9e-4U-cwC">
<rect key="frame" x="0.0" y="64" width="320" height="504"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Blue Label Hosting Login" lineBreakMode="tailTruncation" minimumFontSize="10" translatesAutoresizingMaskIntoConstraints="NO" id="SuD-JI-L2T">
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Username" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="NeI-zB-U8Y">
<constraints>
<constraint firstAttribute="height" constant="31" id="BlH-cG-Jdh"/>
<constraint firstAttribute="width" constant="208" id="Osb-tj-fjn"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Password" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="4Fi-NX-kli">
<constraints>
<constraint firstAttribute="height" constant="31" id="X3j-X2-ton"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits" secureTextEntry="YES"/>
</textField>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="5o5-83-KbW">
<constraints>
<constraint firstAttribute="height" constant="36" id="Afu-6h-uru"/>
<constraint firstAttribute="width" constant="161" id="Ef5-df-Jmp"/>
</constraints>
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
<state key="normal" title="Login">
<color key="titleColor" red="0.19607843459999999" green="0.30980393290000002" blue="0.52156865600000002" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="highlighted">
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="btnLoginRegisterTapped:" destination="w9e-4U-cwC" eventType="touchUpInside" id="Wgb-L8-sAJ"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
<constraints>
<constraint firstItem="NeI-zB-U8Y" firstAttribute="top" secondItem="SuD-JI-L2T" secondAttribute="bottom" constant="8" symbolic="YES" type="default" id="0Pv-zM-WId"/>
<constraint firstItem="4Fi-NX-kli" firstAttribute="top" secondItem="NeI-zB-U8Y" secondAttribute="bottom" constant="8" symbolic="YES" type="default" id="2Sw-m8-LND"/>
<constraint firstItem="4Fi-NX-kli" firstAttribute="trailing" secondItem="NeI-zB-U8Y" secondAttribute="trailing" type="default" id="88O-VQ-qut"/>
<constraint firstItem="SuD-JI-L2T" firstAttribute="centerX" secondItem="NeI-zB-U8Y" secondAttribute="centerX" type="default" id="Qu9-PG-YWz"/>
<constraint firstItem="4Fi-NX-kli" firstAttribute="centerX" secondItem="5o5-83-KbW" secondAttribute="centerX" type="default" id="RAm-sI-Z3u"/>
<constraint firstItem="5o5-83-KbW" firstAttribute="top" secondItem="w9e-4U-cwC" secondAttribute="top" constant="128" id="UTG-NS-bx4"/>
<constraint firstItem="SuD-JI-L2T" firstAttribute="top" secondItem="w9e-4U-cwC" secondAttribute="top" constant="20" symbolic="YES" type="default" id="iaC-Ex-EBa"/>
<constraint firstItem="SuD-JI-L2T" firstAttribute="centerX" secondItem="w9e-4U-cwC" secondAttribute="centerX" type="default" id="oWP-Gp-Pi5"/>
<constraint firstItem="4Fi-NX-kli" firstAttribute="leading" secondItem="NeI-zB-U8Y" secondAttribute="leading" type="default" id="oxE-WD-fVc"/>
</constraints>
<connections>
<outlet property="fldPassword" destination="4Fi-NX-kli" id="4eb-YW-8YI"/>
<outlet property="fldUsername" destination="NeI-zB-U8Y" id="Ds4-XS-iqW"/>
</connections>
</view>
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="FL3-Yk-JbH" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-84" y="-349"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="fJ6-wq-4Tj">
<objects>
<navigationController id="A8c-eR-geg" sceneMemberID="viewController">
<toolbarItems/>
<navigationBar key="navigationBar" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" id="bnk-dD-E4j">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
<connections>
<segue destination="T0P-Bi-31w" kind="relationship" relationship="rootViewController" id="3jA-WY-c3V"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="lTO-TW-owb" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-971" y="-910"/>
</scene>
</scenes>
<classes>
<class className="LoginScreen" superclassName="UIViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/LoginScreen.h"/>
<relationships>
<relationship kind="action" name="btnLoginRegisterTapped:"/>
<relationship kind="outlet" name="fldPassword" candidateClass="UITextField"/>
<relationship kind="outlet" name="fldUsername" candidateClass="UITextField"/>
</relationships>
</class>
<class className="NSLayoutConstraint" superclassName="NSObject">
<source key="sourceIdentifier" type="project" relativePath="./Classes/NSLayoutConstraint.h"/>
</class>
<class className="TicketsView" superclassName="UIViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/TicketsView.h"/>
</class>
</classes>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
<simulatedOrientationMetrics key="orientation"/>
<simulatedScreenMetrics key="destination" type="retina4"/>
</simulatedMetricsContainer>
</document>
이러한 설명 할 수없는 예외는 종종 부정확 한 xib
파일 의 결과입니다 . xib
in xcode를 열고 File 's Owner를 선택한 다음 "Connection Inspector"(오른쪽 위 화살표)를 클릭하면 모든 콘센트를 한 번에 볼 수 있습니다. !
콘센트가 없음을 나타내는 s를 찾으 십시오.
Interface Builder에서 연결을 확인하십시오. 존재하지 않는 IBOutlet
또는 IBAction
.
감사합니다. 당신의 도움으로이 문제를 해결했습니다. 그래서이 스크린 샷이 같은 문제가있는 사람에게 도움이되기를 바랍니다.
Xcode의 중단 점 탭으로 이동합니다. 하단의 버튼을 사용하여 예외 중단 점을 추가하십시오. 이제 setValue : forKey : 및 관련 스택을 호출하는 코드를 볼 수 있습니다. 운이 좋으면 문제의 원인을 바로 알 수 있습니다.
클래스가 LoginScreen이라는 것이 이상하지만 누군가가 "LoginScreen"을 키로 사용하고 있다는 오류입니다. LoginScreen.m이 대상의 일부인지 확인하십시오.
Footnote: with Swift a common problem arises if you change the name of a class (so, you rename it everywhere in your code). Storyboard struggles with this, and you usually have to re-drag any connections involving that class. And in particular, re-enter the name of the class anywhere used in IdentityInspector tab on the right. (In the picture example I deliberately misspelled the class name. But the same thing often happens when you rename a class; even though it's seemingly correct in IdentityInspector, you need to enter the name again; it will correctly autocomplete and you're good to go.)
I had similar issue with creating custom TableCell. The issue was that I set FileOwner to my custom class and then connected outlets.
FileOwner should remain NSObject.
I had this and looked over everything and didn't see any problems, but eventually remembered to try Clean and clear Derived Data and that solved it!
I had a similar problem, but I was using initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
explicitly using the name of the class as the string passed (yes bad form!).
I ended up deleting and re-creating the view controller using a slightly different name but neglected to change the string specified in the method, thus my old version was still used - even though it was in the trash!
I will likely use this structure going forward as suggested in: Is passing two nil paramters to initWithNibName:bundle: method bad practice (i.e. unsafe or slower)?
- (id)init
{
[super initWithNibName:@"MyNib" bundle:nil];
... typical initialization ...
return self;
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
return [self init];
}
Hopefully this helps someone!
This error is something else!
Here is how i Fixed it. I'm using xcode Version 6.1.1 and using swift. I got this error every time my app tried to perform a segue to jump to the next screen. Here what I did.
- Checked that the button was connected to the right action.(This wasn't the problem, but still good to check)
- Check that the button does not have any additional actions or outlets that you may have created by mistake. (This wasn't the problem, but still good to check)
- Check the logs and make sure that all the buttons in the NEXT SCREEN have the correct actions, and if there are any segues, make sure that they have a unique identifier. (This was the problem)
- One of the segues did not have a unique identifier
- One of the buttons had an action and two outlets that I created by mistake.
Delete any additional outlets and make sure that you the segues to the next screen have unique identifiers.
Cheers,
I had this problem because I was not using StoryBorad, and on the project properties -> Deploy info -> Main interface was the name of the Main Xib.
I deleted the value in Main Interface and solved the problem.
I ran into a similar error when creating a custom view class, that was because somehow one of the outlet got hooked up twice in the XIB file(I think I initially control dragged the control directly to the code, but latter control dragged again from the File's owner). I opened the XIB file and remove one of them, after that everything worked fine. Hopefully this helps.
I got this one on a PickerView of all places. The error message was naming the problem with "queuePicker" at the first of the message. It was caused by a previous Referencing Outlet which was no long valid after I added a component and renamed the original NSArray something other than queuePicker. CNTL+click on your StoryBoard object gives you the connections. I clicked the "x" next to the ViewController for queuePicker in Referencing Outlets, made a new connection, and viola, no more crashes.
You're probably setting a value for a key in the alertView, which is not allowed. The key is in this case LoginScreen
. I don't see any call to setValue()
, so I assume it's somewhere else in the code.
I encountered this same problem today. As suggested in this answer, the problem was an unclean xib. In my case the unclean xib was the result of updating a xib that was being loaded by something other than the view controller it was associated with.
Xcode let me create and populate a new outlet and connected it to the file's owner even though I explicitly connected it to the source of the correct view controller. Here's the code generated by Xcode:
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="LoginViewController"]]>
<connections>
<outlet property="hostLabel" destination="W4x-T2-Mcm" id="c3E-1U-sVf"/>
</connections>
</placeholder>
When I ran my app it crashed with the same not key value coding-compliant
error. To correct the problem, I removed the outlet from the File's Owner in Interface Builder and connected it explicitly to the view controller object on the left outline instead of to the code in the assistant editor.
This happened to me in the following scenario:
I created a second project in my workspace, chose "Single View Application" for the template.
I then went to Interface Builder (main iPhone storyboard), added a UISwitch
to the main view, and connected it to the view controller through both an IBOutlet
and an IBAction
(-valueChanged:
).
On launch, the app crashes with the exception mentioned in the question. If I remove the switch from the view, it works.
After careful inspection, I realized I control-dragged the connections into the ViewController.h
of another project in the same workspace. The 'Automatic' set of Interface Builder's Assistant Editor (a.k.a Tuxedo chest icon) chose as "counterpart" the wrong file (with the right name).
Hope this helps someone, specially because both 'Single View Application' and 'SpriteKit Game' project templates (in my case) create a default view controller class called "ViewController".
If you have different storybord files and if you have outlet references with out outlets creation in your header files then you just remove the connections by right clicking on files owner.
Files owner->Right click->remove unwanted connection over there.
Go through this for clear explanation. What does this mean? "'NSUnknownKeyException', reason: … this class is not key value coding-compliant for the key X"
This usually means that something is trying to access the @property "givenName".
If you were doing something with Interface Builder(IB)
, the usual cause is that you either:
- deleted that property from the class, but haven't deleted the hookups in IB yet
- OR: you have a File's Owner object set to the wrong class (check the properties - different depending which version of xcode you're using
- to find the Class Name its set as. You probably copy/pasted a NIB file, and didn't change this field in the NIB), and you've hooked up an outlet for that class, but your actual File's Owner is something different
In my case I have IBOutlet UILabel *description in .h, it was with yellow /!\ - "will not synthesized", as I remember. Dunno what is it and why only this label.
하지만 위와 같은 충돌과 오류가 발생했습니다. * description을 삭제하고 * description2를 다시 만듭니다. 결과에 충돌이 없습니다.
나를 위해 펜촉을 등록하는 컬렉션 뷰 헤더에 대한 호출을 클래스 등록으로 전환했습니다. 그것은 그것을 고쳤습니다.
두 가지 기능이 없기 때문입니다.
@implementation CellTableView
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
return [self init];
}
- (void)awakeFromNib {
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
}
@end
모든 개체를 삭제하고 다시 추가해야했습니다. 이것은 문제를 해결 한 것 같습니다.
'Development Tip' 카테고리의 다른 글
Android에서 툴바 뒤로 버튼의 색상을 변경하는 방법은 무엇입니까? (0) | 2020.10.30 |
---|---|
Android는 gridlayoutmanager를 사용하여 recyclerview의 마지막 요소 아래에 간격을 추가합니다. (0) | 2020.10.30 |
PHP의 GOTO가 악한가요? (0) | 2020.10.30 |
배울 수있는 최고의 오픈 소스 게임은 무엇입니까? (0) | 2020.10.30 |
예상 프로젝트 완료 날짜를 늘리십니까? (0) | 2020.10.30 |