Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/110.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios NSString导致NSThread泄漏_Ios_Objective C_Memory Leaks - Fatal编程技术网

Ios NSString导致NSThread泄漏

Ios NSString导致NSThread泄漏,ios,objective-c,memory-leaks,Ios,Objective C,Memory Leaks,我正在努力解决nshread中NSString引入的内存泄漏问题。请看下面 NSThread* myThread = [[NSThread alloc] initWithTarget:self selector:@selector(testSomething) object:nil]; [myThread start]; - (void)testSomething { while (1) { @autoreleasepool { N

我正在努力解决
nshread
NSString
引入的内存泄漏问题。请看下面

NSThread* myThread = [[NSThread alloc] initWithTarget:self selector:@selector(testSomething) object:nil];

[myThread start];

- (void)testSomething
{
   while (1) {
        @autoreleasepool
        {
           NSString *str = [NSString stringWithFormat:@"%@", [NSDate date]];
           // NSLog(@"%@", str);
        }
        [NSThread sleepForTimeInterval:.1];
    }
}
这个漏洞是由
NSString*str
引起的,但是如何在ARC中修复它呢


我不知道。我已经和探查器核对过了;但是如果我使用
CFStringRef hello=CFSTR(“你好,世界”);CFRelease(你好)没有泄漏…

该代码中没有泄漏。Xcode是错误的。我猜您只会得到一个未使用变量“str”的警告。但是@autoreleasepool应该足够了。