0
更新大约20个图像联系人后,出现内存不足警告。我已经放置了代码。谁能告诉可能是什么原因?使用API的内存不足警告:ABPersonSetImageData
NSString *imagepath = [[IDLFactory documentsDirectoryPath] stringByAppendingFormat:@"/%@",value];
NSData *dataRef = [[NSData alloc] initWithContentsOfFile:imagepath];
CFDataRef cfdata = CFDataCreate(NULL, [dataRef bytes], [dataRef length]);
[dataRef release];
dataRef = nil;
CFErrorRef error;
ABPersonRemoveImageData(inContact, &error); // <-- clean any image first from ref
BOOL ret = ABPersonSetImageData(inContact, cfdata, &error);
if (ret)
{
ret = ABAddressBookSave(inAddressBook, &error);
} else
{
NSLog(@"Could not write the image to the person");
}
CFRelease(cfdata);
在此先感谢
- 如果存在任何图像,ABPersonRemoveImageData()将被移除,否则它将返回FALSE作为返回值。它不会填充新的数据。 - 我没有使用任何autorelease对象在这里使用autoreleasePool。无论如何,我在我调用此片段的方法中使用autoreleasePool。 – Manjunath 2010-11-24 04:35:02