这是给我的iCarouselViewController.m
- (void)dealloc
{
//it's a good idea to set these to nil here to avoid
//sending messages to a deallocated viewcontroller
carousel1.delegate = nil;
carousel1.dataSource = nil;
carousel2.delegate = nil;
carousel2.dataSource = nil;
[carousel1 release];
[carousel2 release];
[items1 release];
[items2 release];
[super dealloc];
}
我收到一条错误消息
'release' 不可用:在自动引用计数模式下不可用
ARC 禁止显式消息发送'release'
'release' 不可用:在自动引用计数模式下不可用
ARC 禁止显式消息发送'release'
'release' 不可用:在自动引用计数模式下不可用
ARC 禁止显式发送“release”消息
“release”不可用:在自动引用计数模式下不可用
ARC 禁止显式发送“release”
消息 ARC 禁止显式发送“dealloc”消息
以及此代码中的错误
- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view
{
UILabel *label = nil;
//create new view if no view is available for recycling
if (view == nil)
{
view = [[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 200.0f, 200.0f)] autorelease];
((UIImageView *)view).image = [UIImage imageNamed:@"page.png"];
view.contentMode = UIViewContentModeCenter;
label = [[[UILabel alloc] initWithFrame:view.bounds] autorelease];
label.backgroundColor = [UIColor clearColor];
label.textAlignment = UITextAlignmentCenter;
label.font = [label.font fontWithSize:50];
[view addSubview:label];
}
else
{
label = [[view subviews] lastObject];
}
说
'autorelease' 不可用:在自动引用计数模式下不可用
ARC 禁止显式消息发送'autorelease'
'autorelease' 不可用:在自动引用计数模式下不可用
ARC 禁止显式消息发送'autorelease'
我怎样才能清除这个错误。
更新
感谢您的回答我只有 4 个错误说使用未声明的标识符 imageArray1。我知道这正在发生。我只是不明白“我假设你只是在使用应用程序的包,我们有两个 NSString 数组,它们引用每个图像:imageArray1 和 imageArray2。” 下面是我的保存代码之一,并为我的一个目录创建目录。注意:我只有一个名为 allImagesArray 的 NSMutableArray,我在头文件中声明了它。
NSArray *directoryNames = [NSArray arrayWithObjects:@"Apple",nil];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0]; // Get documents folder
for (int i = 0; i < [directoryNames count] ; i++) {
NSString *dataPath = [documentsDirectory stringByAppendingPathComponent:[directoryNames objectAtIndex:i]];
if (![[NSFileManager defaultManager] fileExistsAtPath:dataPath])
[[NSFileManager defaultManager] createDirectoryAtPath:dataPath withIntermediateDirectories:NO attributes:nil error:nil]; //Create folder
NSString *folderPath = [documentsDirectory stringByAppendingPathComponent:@"Tops"]; NSData *imageData = UIImagePNGRepresentation(captureImage.image);
time_t unixtime = (time_t)[[NSDate date]timeIntervalSince1970];
NSString *timestamp = [NSString stringWithFormat:@"%ldTopsImage.PNG",unixtime];
NSString *filePath = [folderPath stringByAppendingPathComponent:timestamp];
[imageData writeToFile:filePath atomically:YES];
}
}
更新 4
这是?
- (void)viewDidLoad
{
[super viewDidLoad];
//configure carousel
imageArray1 = [[NSMutableArray alloc] init];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *location=@"apple";
NSString *fPath = [documentsDirectory stringByAppendingPathComponent:location];
NSArray * directoryContent = [[NSFileManager defaultManager] directoryContentsAtPath: fPath];
imageArray1 = directoryContent;
imageArray2 = [[NSMutableArray alloc] init];
NSString *location=@"green";
NSString *fPath = [documentsDirectory stringByAppendingPathComponent:location];
NSArray *directoryContent = [[NSFileManager defaultManager] directoryContentsAtPath: fPath];
imageArray2 = directoryContent;