에는 풀과 오토 릴리즈 :개체 장소
#import <Foundation/Foundation.h>
bool trigger = false;
NSLock *theLock=[NSLock new];
@interface Metronome : NSObject
+(void)tick:(id)param;
@end
@implementation Metronome
+(void)tick:(id)param{
while(1)
{
NSLog(@"TICK\n");
usleep(1000000);
[theLock lock];
trigger = true;
[theLock unlock];
}
}
@end
int main()
{
[NSThread detachNewThreadSelector:@selector(tick:)
toTarget:[Metronome class] withObject:nil];
}
더 컴파일 오류가 없다, 그러나 실행 중에 콘솔은 다음과 같은 경고를 팝업 :
objc[688]: Object 0x100300ff0 of class NSThread autoreleased with no pool
in place - just leaking - break on objc_autoreleaseNoPool() to debug
obj-C의 메모리 관리에 익숙하지 않습니다. 누군가 나에게 이것을 설명 할 수 있습니까? 고마워요!