저는 최근 Lynda.com iOs SDK 필수 과정을 통해 Obj-C 및 Iphone 개발을 배우기 시작했습니다. 그러나 Xcode 3.x 용으로 작성되었으며 4.0.x가 설치되어 있으므로 상황이 다릅니다. 기본적으로, 나는 거기에서 예제를 취하고 그것은 단지 나를 위해 작동하지 않으며 나는 그것의 멍청이가되는 걸 알아낼 수 없습니다.iOs 간단한 안녕하세요, 이름이 작동하지 않습니다.
//basicViewController.h
#import <UIKit/UIKit.h>
@interface basicViewController : UIViewController {
IBOutlet UITextField *txtName;
IBOutlet UILabel *lblMessage;
}
@property (nonatomic, retain) IBOutlet UITextField *txtName;
@property (nonatomic, retain) IBOutlet UILabel *lblMessage;
- (IBAction) doSomething;
@end
그리고 내 basicViewController.m
#import "basicViewController.h"
@implementation basicViewController
@synthesize txtName;
@synthesize lblMessage;
- (IBAction) doSomething
{
NSString *msg = [[NSString alloc] initWithFormat:@"Hello, %@",txtName.text];
[lblMessage setText:msg];
[msg release];
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[super dealloc];
}
@end
나는 그들이 같이 생성 된 것과 basicAppDelegate.h와하는 .m을 변경되지 않았습니다. 나는 그들이 어쨌든 그들을 게시 할 것 같아요. 또한
//
// main.m
#import <UIKit/UIKit.h>
int main(int argc, char *argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
return retVal;
}
, 내가 파일의 소유자를 통해 연결 한 인터페이스 빌더 창에서 : lblMessage에 라벨, 버튼의 txtName 및 해봐요에 텍스트 필드
//
// basicAppDelegate.h
#import <UIKit/UIKit.h>
@class basicViewController;
@interface basicAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
basicViewController *viewController;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet basicViewController *viewController;
@end
//
// basicAppDelegate.m
#import "basicAppDelegate.h"
#import "basicViewController.h"
@implementation basicAppDelegate
@synthesize window;
@synthesize viewController;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Override point for customization after app launch
[window addSubview:viewController.view];
[window makeKeyAndVisible];
}
- (void)dealloc {
[viewController release];
[window release];
[super dealloc];
}
@end
그리고 여기 내 main.m입니다.
지금 문제는 실제로 물리적 키보드가 아닌 실제 키보드를 사용하는 경우입니다. 그리고 내가 3-4-5 기호보다 적게 입력하는 경우에만 (때때로 다른 경우). 키보드를 사용하는 경우가 아니라 팝업을 사용하면 스레드 1 수신 신호 EXC_BAD_ACCESS가됩니다. 너무 많은 기호를 입력하면 동일합니다.
그리고 모든 출력에서 많이 볼 수 없습니다 - 그냥 보통 물건은 유일한 의심스러운 라인은 다음과 같습니다
warning:unable to compile regular expression "dyld"
Current language: auto; currently objective-c
(gdb)
그래서, 사람이, 어떤 종류의 도움에 감사드립니다.
이와 함께 문자열 형식 라인을 교체 시도하고 다음 두 줄 아래의 릴리스를 제거 할 수 있습니까? NSString * msg = [NSString stringWithFormat : @ "Hello, % @", txtName.text]; – bryanmac
아무 것도 변경되지 않습니다. 핸들러를 비워 둘 수도 있습니다. 텍스트 필드에 텍스트를 입력하는 동안 문제가 발생하는 것 같습니다. 버튼을 누르지도 않았습니다. 버튼이 정상적으로 작동하므로 ... –
환경 변수로 NSZombieEnabled를 사용하여 응용 프로그램을 실행하고 로그 출력을 확인하십시오. Alt 키를 누른 상태에서 '실행'메뉴 항목을 실행하고 'NSZombieEnabled'를 인수 환경 변수에 YES로 추가하십시오. – Rengers