저는 간단한 계산기를 코딩하고 있으며 4 개의 산술 연산 버튼 모두에 대해 고유 한 함수를 만들고 싶습니다. 나는 여기에있다 :Objective-C에 충돌을 일으키는 간단한 함수
-(IBAction)simbolo1:(UIButton*)sender{
if (isNumeric(campo1.text)) {
NSString *str=campo1.text;
campo2.text=str;
int S=1;
NSString *cmp1 = [NSString stringWithFormat:@"%d", S];
sinal.text=cmp1;
[email protected]"";
} else {
[email protected]"Only numeric values";
}
}
그러나, 나는 이것을 작동시킬 수 없다. 버튼을 클릭 할 때마다 충돌이 발생합니다. 마커 : 코드의
-(void)simbolo1:(UIButton*)sender{
[email protected]"Only numeric values";
}
그 선이
전에 나는 '녹색납니다로 나에게 같은 오류를 준 것으로 보인다 : 그래서, 난 정말 어디에서 오류가 있었고, 난 전체 코드를 삭제 확인 '이 파일 :
2011-09-30 09:17:14.319 Teste iPhone[28432:fb03] Applications are expected to have a root view controller at the end of application launch
2011-09-30 09:17:21.714 Teste iPhone[28432:fb03] -[Teste_iPhoneAppDelegate simbolo1]: unrecognized selector sent to instance 0x6b7c2d0
2011-09-30 09:17:21.715 Teste iPhone[28432:fb03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Teste_iPhoneAppDelegate simbolo1]: unrecognized selector sent to instance 0x6b7c2d0'
*** First throw call stack:
(0x166d062 0x17fed0a 0x166ecfd 0x15d3f10 0x15d3cf2 0x166eed9 0x16eb2 0x16e4a 0xbc3e6 0xbc8af 0xbbb6e 0x3c2a0 0x3c4c6 0x22c74 0x16399 0x1557fa9 0x16411d5 0x15a6042 0x15a492a 0x15a3dd4 0x15a3ceb 0x1556879 0x155693e 0x1438b 0x272d 0x26a5)
terminate called throwing an exception(gdb)
,369 :
#import <UIKit/UIKit.h>
int main(int argc, char *argv[]){
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil); <--------- This line right here
[pool release];
return retVal;
}
편집 --------------- debud 콘솔 메신저에이 점점
에 적절한의 UITextField에
IBOutlet UITextField* campo1;
을 연결하는 것을 잊지 마세요 설정하는 방법? 적절한 헤더 파일을 보여주십시오 –디버거 콘솔을보십시오. (1) 거기에 인쇄 된 오류는 무엇입니까 (2) 스택 무엇입니까? –
오, 죄송합니다. 'campo1'은 UITextField입니다. isNumeric은 문자열이 숫자인지 검사하는 함수입니다. – markus