2013-03-04 2 views
0

Paul Hegarty의 CS193P 코스 비디오 (강의 # 4 @ 1:05:40 마크)를 따라 가고 문제가 발생했습니다. 이 '인스턴스로 전송 된 인식 할 수없는 선택기'오류를 디버그하십시오. 이미지 (https://docs.google.com/file/d/0B453_F6cDmYzMG1OQW93WVptYUU/edit?usp=sharing)를 참조Paul Hegarty 's CS193P

코드

// AttributeViewController.m 
    // Attribute 

    #import "AttributeViewController.h" 

    @interface AttributeViewController() 
    @property (weak, nonatomic) IBOutlet UILabel *label;     // collection of words 
    @property (weak, nonatomic) IBOutlet UIStepper *selectedWordStepper; // stepper 
    @property (weak, nonatomic) IBOutlet UILabel *selectedWordLabel;  // selected word from label 

    @end 

    @implementation AttributeViewController 

    - (NSArray *)wordList 
    { 
     NSArray *wordList = [[self.label.attributedText string] componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; 
     if ([wordList count]) { 
      return wordList; 
     } else { 
      return @[@""]; 
     } 
    } 

    - (NSString *)selectedWord 
    { 
     return [self wordList][(int)self.selectedWordStepper.value]; 
    } 

    - (IBAction)updateSelectedWord { 
     self.selectedWordStepper.maximumValue = [[self wordList] count]-1; 
     self.selectedWordLabel.text = [self selectedWord]; 
    } 

    - (void)viewDidLoad 
    { 
     [super viewDidLoad]; 
    // Do any additional setup after loading the view, typically from a nib. 
     [self updateSelectedWord]; 
    } 

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

    @end 

정말 전에 IBAction를 메소드를 직접 호출을 보지 못한 오류

2013-03-03 18:03:28.948 Attribute[74205:c07] -[AttributeViewController updateSelectedWord:]: unrecognized selector sent to instance 0x71b93a0 
2013-03-03 18:03:28.952 Attribute[74205:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AttributeViewController updateSelectedWord:]: unrecognized selector sent to instance 0x71b93a0' 
*** First throw call stack: 
(0x1c91012 0x10cee7e 0x1d1c4bd 0x1c80bbc 0x1c8094e 0x10e2705 0x162c0 0x16258 0xd7021 0xd757f 0xd7056 0x42b195 0x42ae91 0xd6696 0x45cef 0x45f02 0x23d4a 0x15698 0x1becdf9 0x1c14f3f 0x1c1496f 0x1c37734 0x1c36f44 0x1c36e1b 0x1beb7e3 0x1beb668 0x12ffc 0x25cd 0x24f5) 
libc++abi.dylib: terminate called throwing an exception 
(lldb) gdb 

답변

0

- 뷰는 세 가지 목적을 가지고있다. IBAction 메서드는보기 (단추 등)의 동작에 연결되며이 단추 등을 클릭하면 트리거됩니다. updateSelectedWord 내부 방법 인 경우

, 단지 무효로 IBAction를 대체 :이 도움이

(void)updateSelectedWord 

희망을.

+0

고맙습니다. Spectravideo. 나는 그것을 시험해 보았고 스테퍼와의 연결을 끊었다. 스테퍼가 필요로하는 것 같습니다 (IBAction) - 이미지보기 https://docs.google.com/file/d/0B453_F6cDmYzZVp2M3lZV2loQkU/edit?usp=sharing 변경 여부와 상관없이 동일한 오류가 있습니다. – TaniOS

+0

왜 2 액션이 값 변경에 연결되어 있습니까? 나는 둘 다 연결을 끊고 올바른 방법으로 만 다시 연결합니다. IBAction 메서드 이름을 업데이트했거나 .h 파일에서 약간 다르게 선언 한 것처럼 보입니다. 전달할 인수가 있는지 여부를 포함하여 .h 및 .m 파일에서 IBAction 메서드의 이름이 동일한 지 확인하십시오. – Spectravideo328

+0

두 메서드를 모두 연결 해제하고 다시 연결했습니다. 올바른 것으로 수정하십시오. 여전히 같은 문제가 있습니다. 마지막으로 스테퍼를 삭제하고 다시 추가했습니다. 그리고 그것은 작동합니다! 왜 그것이 전에 작동하지 않았는지 모르겠습니다. :) 당신의 도움을 주셔서 감사합니다. 정리 된 스테퍼의 이미지는 다음과 같습니다. https://docs.google.com/file/d/0B453_F6cDmYzM29nbUl5b0U5TVE/edit?usp=sharing – TaniOS