2013-06-16 8 views
0

이것은 나를 미치게합니다!iOS [__NSArrayM insertObject : atIndex :] : 객체가 무효가 될 수 없습니다.

내가보고 있어요 '* - [__ NSArrayM은 insertObject : atIndex :] : 객체가 될 수 없다 전무'

응용 프로그램을 종료

* 인해 캐치되지 않는 예외 'NSInvalidArgumentException', 이유에 * 먼저 던져 호출 스택 : (0x28f9012 0x271ee7e 0x28acb6a 0x28aca20 0x5866c 0x5eeee 0x154f103 0x154f42b 0x155cf80 0x1564fad 0x156589b 0x1565e93 0x1565a88 0x8628 0x2732705 0x146f2c0 0x16aba64 0x2732705 0x146f2c0 0x146f258 0x1530021 0x153057f 0x152f6e8 0x149ecef 0x149ef02 0x147cd4a 0x146e698 0x2d76df9 0x2d76ad0 0x286ebf5 0x286e962 0x289fbb6 0x289ef44 0x289ee1b 0x2d757e3 0x2d75668 0x146bffc 0x3210 0x3175) 의 libC++ abi.dylib : 호출 종료에

첫 번째 브레이크 포인트 잡기되는 예외를 던지는이 갑자기 문제가되기 시작했다 방법

NSMutableArray *imgArray = [NSMutableArray array]; 
    IMReviewView *subview = [[IMReviewView alloc] initWithFrame:frame]; 
    subview.delegate = self; 
    subview.photo = [[IMLocalUser localUser] cachedPhotoAtIndex:0]; 
    UIImage *img1 = [[UIImage alloc] init]; 
    img1 = subview.photo.image; 
    [imgArray addObject:img1]; //Breaking Here.... 

확실하지, 이전 빌드로 복원했지만 다른 워크 스테이션에서 여전히 아래 코드에서이 오류가 발생했습니다.

아이디어가 있습니까?

[imgArray addObject:img1]; 

img1nil 것을 의미 오류가 행하므로

@implementation IMReviewViewController { 
    UIScrollView *scrollView; 
    //UIPageControl *pageControl; 
    BOOL continueButtonDisabled; 
    NSUInteger downloadedImageCount; 
} 

@synthesize frameImage; 

@synthesize removeButton; 
@synthesize caption; 
@synthesize delegate; 
@synthesize photo = _photo; 

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
{ 
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
    if (self) { 
    } 
    return self; 
} 

- (void)dealloc 
{ 
    NSLog(@"dealloc - IMReviewViewController"); 
} 

- (void)buttonPressed:(id)sender 
{ 
    // if (self.delegate && [self.delegate respondsToSelector:@selector(removePhoto:)]) { 
    //  [self.delegate removePhoto:removePhoto:self.photo]; 
    // } 

    for (UIView *view in scrollView.subviews) { 
     [view removeFromSuperview]; 
    } 

    [self.navigationController popViewControllerAnimated:YES]; 
} 

- (void)drawRect:(CGRect)rect 
{ 
    // Drawing code 
    CGContextRef context = UIGraphicsGetCurrentContext(); 
    CGContextSetShadow(context, CGSizeMake(3.0f, 3.0f), 2.0f); 

    if (self.frameImage) { 
     [self.frameImage drawInRect:rect]; 
    } 
} 

- (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. 
} 

#pragma mark - View lifecycle 

- (void)setReviewImages 
{ 
    continueButtonDisabled = YES; 
    downloadedImageCount = 0; 

    NSArray *reviewViews = scrollView.subviews; 
    for (IMReviewView *reviewView in reviewViews) { 
     [reviewView removeFromSuperview]; 
    } 

    NSUInteger photoCount = [[IMLocalUser localUser] cachedPhotoCount]; 
    if (nPageNum == 0){ 
     for (NSUInteger i = 0; i < photoCount; i++) { 

      CGRect frame; 
      frame.origin.x = scrollView.frame.size.width * i; 
      frame.origin.y = 65; 
      frame.size  = CGSizeMake(scrollView.frame.size.width, 327.0f); 

      IMReviewView *subview = [[IMReviewView alloc] initWithFrame:frame]; 
      subview.delegate = self; 
      subview.photo = [[IMLocalUser localUser] cachedPhotoAtIndex:i]; 
      [scrollView addSubview:subview]; 

      scrollView.showsHorizontalScrollIndicator = NO; 
      scrollView.contentSize = CGSizeMake(scrollView.frame.size.width * i, scrollView.frame.size.height); 

      UILabel *headingLabel = [[UILabel alloc] initWithFrame:CGRectMake(12, 20, 300, 30)]; 
      [self.view addSubview:headingLabel]; 


      headingLabel.text = @"Time To Preview!"; 
      headingLabel.textColor = [UIColor blackColor]; 
      headingLabel.textAlignment = UITextAlignmentCenter; 

      headingLabel.textAlignment = NSTextAlignmentCenter; 
      headingLabel.tag = 10; 
      headingLabel.backgroundColor = [UIColor clearColor]; 
      headingLabel.font = [UIFont boldSystemFontOfSize:26.0f]; 
      headingLabel.hidden = NO; 
      headingLabel.highlighted = YES; 
      headingLabel.highlightedTextColor = [UIColor blackColor]; 
      headingLabel.lineBreakMode = YES; 
      headingLabel.numberOfLines = 0; 
     } 

     // pageControl.numberOfPages = photoCoun 
    }else if(nPageNum == 1){ 

     int nVWidth, nVHeight; 
     nVWidth = self.view.frame.size.width; 
     nVHeight = (self.view.frame.size.height - 310)/2; 

     CGRect frame; 
     frame.origin.x = 27.0f; 
     frame.origin.y = 65; 
     frame.size  = CGSizeMake(269.5f, 253.5f); 

     IMReviewView *subview = [[IMReviewView alloc] initWithFrame:frame]; 
     subview.delegate = self; 
     subview.photo = [[IMLocalUser localUser] cachedPhotoAtIndex:0]; 
     UIImage *img1 = [[UIImage alloc] init]; 
     img1 = subview.photo.image; 

     NSURL *imageURL = [[NSBundle mainBundle] URLForResource:@"FramedBack" withExtension:@"png"]; 
     frameImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:imageURL]]; 

     //Header Text above print 

     UILabel *headingLabel = [[UILabel alloc] initWithFrame:CGRectMake(12, 20, 300, 30)]; 
     [self.view addSubview:headingLabel]; 


     headingLabel.text = @"Time To Preview!"; 
     headingLabel.textColor = [UIColor blackColor]; 
     headingLabel.textAlignment = UITextAlignmentCenter; 

     headingLabel.textAlignment = NSTextAlignmentCenter; 
     headingLabel.tag = 10; 
     headingLabel.backgroundColor = [UIColor clearColor]; 
     headingLabel.font = [UIFont boldSystemFontOfSize:26.0f]; 
     headingLabel.hidden = NO; 
     headingLabel.highlighted = YES; 
     headingLabel.highlightedTextColor = [UIColor blackColor]; 
     headingLabel.lineBreakMode = YES; 
     headingLabel.numberOfLines = 0; 


     //---------------- 
     UIGraphicsBeginImageContext(CGSizeMake(IMAGE_WIDTH, IMAGE_HEIGHT)); 
     CGSize divSize = CGSizeMake(IMAGE_WIDTH, IMAGE_HEIGHT); 
     UIImage *image = [[UIImage alloc] init]; 

     image = [UIImage imageWithData:[NSData dataWithContentsOfURL:imageURL]]; 
     //image = [image resizedImage:divSize interpolationQuality:kCGInterpolationDefault]; 
     [image drawInRect:CGRectMake(0, 0, IMAGE_WIDTH, IMAGE_HEIGHT)]; 


     image = img1; 
     image = [image resizedImage:divSize interpolationQuality:kCGInterpolationDefault]; 
     [image drawInRect:CGRectMake(300, 300, divSize.width-600, divSize.height-600)]; 

     UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); 

     UIGraphicsEndImageContext(); 

     UIImageView *viewImage = [[UIImageView alloc] initWithImage:newImage]; 
     [viewImage setFrame:frame]; 
     [scrollView addSubview:viewImage]; 

     NSURL *buottonImageURL = [[NSBundle mainBundle] URLForResource:@"[email protected]" withExtension:@"png"]; 
     UIImage *buttonImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:buottonImageURL]]; 
     self.removeButton = [[UIButton alloc] initWithFrame:CGRectMake(13.0f, 50, 38.0f, 38.0f)]; 
     [self.removeButton setImage:buttonImage forState:UIControlStateNormal]; 
     [self.removeButton addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside]; 
     [scrollView addSubview:self.removeButton]; 


     scrollView.showsHorizontalScrollIndicator = NO; 
     scrollView.contentSize = CGSizeMake(scrollView.frame.size.width, scrollView.frame.size.height); 
    }else if(nPageNum == 2){ 
     int nVWidth, nVHeight; 
     nVWidth = self.view.frame.size.width; 
     nVHeight = (self.view.frame.size.height - 330)/2; 

     CGRect frame; 
     frame.origin.x = 27.0f; 
     frame.origin.y = 65; 
     frame.size  = CGSizeMake(269.5f, 253.5f); 


     NSMutableArray *imgArray = [NSMutableArray array]; 
     IMReviewView *subview = [[IMReviewView alloc] initWithFrame:frame]; 
     subview.delegate = self; 
     subview.photo = [[IMLocalUser localUser] cachedPhotoAtIndex:0]; 
     UIImage *img1 = [[UIImage alloc] init]; 
     img1 = subview.photo.image; 
     [imgArray addObject:img1]; 

     subview.photo = [[IMLocalUser localUser] cachedPhotoAtIndex:1]; 
     UIImage *img2 = [[UIImage alloc] init]; 
     img2 = subview.photo.image; 
     [imgArray addObject:img2]; 

     subview.photo = [[IMLocalUser localUser] cachedPhotoAtIndex:2]; 
     UIImage *img3 = [[UIImage alloc] init]; 
     img3 = subview.photo.image; 
     [imgArray addObject:img3]; 

     subview.photo = [[IMLocalUser localUser] cachedPhotoAtIndex:3]; 
     UIImage *img4 = [[UIImage alloc] init]; 
     img4 = subview.photo.image; 
     [imgArray addObject:img4]; 

     NSURL *imageURL = [[NSBundle mainBundle] URLForResource:@"FramedBack" withExtension:@"png"]; 
     frameImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:imageURL]]; 

     //Header Text above print 

     UILabel *headingLabel = [[UILabel alloc] initWithFrame:CGRectMake(12, 20, 300, 30)]; 
     [self.view addSubview:headingLabel]; 


     headingLabel.text = @"Time To Preview!"; 
     headingLabel.textColor = [UIColor blackColor]; 
     headingLabel.textAlignment = UITextAlignmentCenter; 

     headingLabel.textAlignment = NSTextAlignmentCenter; 
     headingLabel.tag = 10; 
     headingLabel.backgroundColor = [UIColor clearColor]; 
     headingLabel.font = [UIFont boldSystemFontOfSize:26.0f]; 
     headingLabel.hidden = NO; 
     headingLabel.highlighted = YES; 
     headingLabel.highlightedTextColor = [UIColor blackColor]; 
     headingLabel.lineBreakMode = YES; 
     headingLabel.numberOfLines = 0; 

     //Footer Text under print 

     UILabel *footer = [[UILabel alloc] initWithFrame:CGRectMake(50, 330, 226, 50)]; 
     [self.view addSubview:footer]; 

     footer.text = @"*Please note, you cannot select the layout of the images within the grid at this time."; 
     footer.textColor = [UIColor blackColor]; 
     footer.textAlignment = UITextAlignmentCenter; 

     footer.textAlignment = NSTextAlignmentCenter; 
     footer.tag = 10; 
     footer.backgroundColor = [UIColor clearColor]; 
     footer.font = [UIFont systemFontOfSize:9.0f]; 
     footer.hidden = NO; 
     footer.highlighted = YES; 
     footer.highlightedTextColor = [UIColor blackColor]; 
     footer.lineBreakMode = YES; 
     footer.numberOfLines = 0; 

     //---------------- 
     UIGraphicsBeginImageContext(CGSizeMake(IMAGE_WIDTH, IMAGE_HEIGHT)); 
     CGSize divSize = CGSizeMake(IMAGE_WIDTH/2, IMAGE_HEIGHT/2); 
     UIImage *image = [[UIImage alloc] init]; 

     image = [UIImage imageWithData:[NSData dataWithContentsOfURL:imageURL]]; 
     image = [image resizedImage:divSize interpolationQuality:kCGInterpolationDefault]; 
     [image drawInRect:CGRectMake(0, 0, IMAGE_WIDTH, IMAGE_HEIGHT)]; 


     image = [imgArray objectAtIndex:0]; 
     image = [image resizedImage:divSize interpolationQuality:kCGInterpolationDefault]; 
     [image drawInRect:CGRectMake(200, 200, divSize.width-210, divSize.height-210)]; 

     image = [imgArray objectAtIndex:1]; 
     image = [image resizedImage:divSize interpolationQuality:kCGInterpolationDefault]; 
     [image drawInRect:CGRectMake(divSize.width, 200, divSize.width-210, divSize.height-210)]; 

     image = [imgArray objectAtIndex:2]; 
     image = [image resizedImage:divSize interpolationQuality:kCGInterpolationDefault]; 
     [image drawInRect:CGRectMake(200, divSize.height, divSize.width-210, divSize.height-210)]; 

     image = [imgArray objectAtIndex:3]; 
     image = [image resizedImage:divSize interpolationQuality:kCGInterpolationDefault]; 
     [image drawInRect:CGRectMake(divSize.width, divSize.height, divSize.width-210, divSize.height-210)]; 

     UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); 

     UIGraphicsEndImageContext(); 

     UIImageView *viewImage = [[UIImageView alloc] initWithImage:newImage]; 
     [viewImage setFrame:frame]; 
     [scrollView addSubview:viewImage]; 

     NSURL *buottonImageURL = [[NSBundle mainBundle] URLForResource:@"[email protected]" withExtension:@"png"]; 
     UIImage *buttonImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:buottonImageURL]]; 
     self.removeButton = [[UIButton alloc] initWithFrame:CGRectMake(13.0f, 50, 38.0f, 38.0f)]; 
     [self.removeButton setImage:buttonImage forState:UIControlStateNormal]; 
     [self.removeButton addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside]; 
     [scrollView addSubview:self.removeButton]; 


     scrollView.showsHorizontalScrollIndicator = NO; 
     scrollView.contentSize = CGSizeMake(scrollView.frame.size.width, scrollView.frame.size.height); 
    }else if(nPageNum == 3){ 
     int nVWidth, nVHeight; 
     nVWidth = self.view.frame.size.width; 
     nVHeight = (self.view.frame.size.height - 243)/2; 
     CGRect frame; 
     frame.origin.x = 27.0f; 
     frame.origin.y = 65; 
     frame.size  = CGSizeMake(269.5f, 253.5f); 

     NSMutableArray *imgArray = [NSMutableArray array]; 
     IMReviewView *subview = [[IMReviewView alloc] initWithFrame:frame]; 
     subview.delegate = self; 
     subview.photo = [[IMLocalUser localUser] cachedPhotoAtIndex:0]; 
     UIImage *img1 = [[UIImage alloc] init]; 
     img1 = subview.photo.image; 
     [imgArray addObject:img1]; 

     subview.photo = [[IMLocalUser localUser] cachedPhotoAtIndex:1]; 
     UIImage *img2 = [[UIImage alloc] init]; 
     img2 = subview.photo.image; 
     [imgArray addObject:img2]; 

     subview.photo = [[IMLocalUser localUser] cachedPhotoAtIndex:2]; 
     UIImage *img3 = [[UIImage alloc] init]; 
     img3 = subview.photo.image; 
     [imgArray addObject:img3]; 

     subview.photo = [[IMLocalUser localUser] cachedPhotoAtIndex:3]; 
     UIImage *img4 = [[UIImage alloc] init]; 
     img4 = subview.photo.image; 
     [imgArray addObject:img4]; 

     subview.photo = [[IMLocalUser localUser] cachedPhotoAtIndex:4]; 
     UIImage *img5 = [[UIImage alloc] init]; 
     img5 = subview.photo.image; 
     [imgArray addObject:img5]; 

     subview.photo = [[IMLocalUser localUser] cachedPhotoAtIndex:5]; 
     UIImage *img6 = [[UIImage alloc] init]; 
     img6 = subview.photo.image; 
     [imgArray addObject:img6]; 

     subview.photo = [[IMLocalUser localUser] cachedPhotoAtIndex:6]; 
     UIImage *img7 = [[UIImage alloc] init]; 
     img7 = subview.photo.image; 
     [imgArray addObject:img7]; 

     subview.photo = [[IMLocalUser localUser] cachedPhotoAtIndex:7]; 
     UIImage *img8 = [[UIImage alloc] init]; 
     img8 = subview.photo.image; 
     [imgArray addObject:img8]; 

     subview.photo = [[IMLocalUser localUser] cachedPhotoAtIndex:8]; 
     UIImage *img9 = [[UIImage alloc] init]; 
     img9 = subview.photo.image; 
     [imgArray addObject:img9]; 

     NSURL *imageURL = [[NSBundle mainBundle] URLForResource:@"FramedBack" withExtension:@"png"]; 
     frameImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:imageURL]]; 

     //Header Text above print 

     UILabel *headingLabel = [[UILabel alloc] initWithFrame:CGRectMake(12, 20, 300, 30)]; 
     [self.view addSubview:headingLabel]; 


     headingLabel.text = @"Time To Preview!"; 
     headingLabel.textColor = [UIColor blackColor]; 
     headingLabel.textAlignment = UITextAlignmentCenter; 

     headingLabel.textAlignment = NSTextAlignmentCenter; 
     headingLabel.tag = 10; 
     headingLabel.backgroundColor = [UIColor clearColor]; 
     headingLabel.font = [UIFont boldSystemFontOfSize:26.0f]; 
     headingLabel.hidden = NO; 
     headingLabel.highlighted = YES; 
     headingLabel.highlightedTextColor = [UIColor blackColor]; 
     headingLabel.lineBreakMode = YES; 
     headingLabel.numberOfLines = 0; 

     //Footer Text under print 

     UILabel *footer = [[UILabel alloc] initWithFrame:CGRectMake(50, 330, 226, 50)]; 
     [self.view addSubview:footer]; 

     footer.text = @"*Please note, you cannot select the layout of the images within the grid at this time."; 
     footer.textColor = [UIColor blackColor]; 
     footer.textAlignment = UITextAlignmentCenter; 

     footer.textAlignment = NSTextAlignmentCenter; 
     footer.tag = 10; 
     footer.backgroundColor = [UIColor clearColor]; 
     footer.font = [UIFont systemFontOfSize:9.0f]; 
     footer.hidden = NO; 
     footer.highlighted = YES; 
     footer.highlightedTextColor = [UIColor blackColor]; 
     footer.lineBreakMode = YES; 
     footer.numberOfLines = 0; 

     //---------------- 
     UIGraphicsBeginImageContext(CGSizeMake(IMAGE_WIDTH, IMAGE_HEIGHT)); 
     CGSize divSize = CGSizeMake(IMAGE_WIDTH/3, IMAGE_HEIGHT/3); 
     UIImage *image = [[UIImage alloc] init]; 

     image = [UIImage imageWithData:[NSData dataWithContentsOfURL:imageURL]]; 
     image = [image resizedImage:divSize interpolationQuality:kCGInterpolationDefault]; 
     [image drawInRect:CGRectMake(0, 0, IMAGE_WIDTH, IMAGE_HEIGHT)]; 


     image = [imgArray objectAtIndex:0]; 
     image = [image resizedImage:divSize interpolationQuality:kCGInterpolationDefault]; 
     [image drawInRect:CGRectMake(210, 210, divSize.width-150, divSize.height-150)]; 

     image = [imgArray objectAtIndex:1]; 
     image = [image resizedImage:divSize interpolationQuality:kCGInterpolationDefault]; 
     [image drawInRect:CGRectMake(divSize.width + 70, 210, divSize.width-150, divSize.height-150)]; 

     image = [imgArray objectAtIndex:2]; 
     image = [image resizedImage:divSize interpolationQuality:kCGInterpolationDefault]; 
     [image drawInRect:CGRectMake(divSize.width * 2 - 70, 210, divSize.width-150, divSize.height-150)]; 

     image = [imgArray objectAtIndex:3]; 
     image = [image resizedImage:divSize interpolationQuality:kCGInterpolationDefault]; 
     [image drawInRect:CGRectMake(210, divSize.height + 70, divSize.width-150, divSize.height-150)]; 

     image = [imgArray objectAtIndex:4]; 
     image = [image resizedImage:divSize interpolationQuality:kCGInterpolationDefault]; 
     [image drawInRect:CGRectMake(divSize.width + 70, divSize.height + 70, divSize.width-150, divSize.height-150)]; 

     image = [imgArray objectAtIndex:5]; 
     image = [image resizedImage:divSize interpolationQuality:kCGInterpolationDefault]; 
     [image drawInRect:CGRectMake(divSize.width * 2 - 70, divSize.height + 70, divSize.width-150, divSize.height-150)]; 

     image = [imgArray objectAtIndex:6]; 
     image = [image resizedImage:divSize interpolationQuality:kCGInterpolationDefault]; 
     [image drawInRect:CGRectMake(210, divSize.height*2 -70, divSize.width-150, divSize.height-150)]; 

     image = [imgArray objectAtIndex:7]; 
     image = [image resizedImage:divSize interpolationQuality:kCGInterpolationDefault]; 
     [image drawInRect:CGRectMake(divSize.width + 70, divSize.height*2 -70, divSize.width-150, divSize.height-150)]; 

     image = [imgArray objectAtIndex:8]; 
     image = [image resizedImage:divSize interpolationQuality:kCGInterpolationDefault]; 
     [image drawInRect:CGRectMake(divSize.width * 2 - 70, divSize.height*2 -70, divSize.width-150, divSize.height-150)]; 

     UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); 

     UIGraphicsEndImageContext(); 

     UIImageView *viewImage = [[UIImageView alloc] initWithImage:newImage]; 
     [viewImage setFrame:frame]; 
     [scrollView addSubview:viewImage]; 

     NSURL *buottonImageURL = [[NSBundle mainBundle] URLForResource:@"[email protected]" withExtension:@"png"]; 
     UIImage *buttonImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:buottonImageURL]]; 
     self.removeButton = [[UIButton alloc] initWithFrame:CGRectMake(13.0f, 50, 38.0f, 38.0f)]; 
     [self.removeButton setImage:buttonImage forState:UIControlStateNormal]; 
     [self.removeButton addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside]; 
     [scrollView addSubview:self.removeButton]; 


     scrollView.showsHorizontalScrollIndicator = NO; 
     scrollView.contentSize = CGSizeMake(scrollView.frame.size.width, scrollView.frame.size.height); 
    }else if(nPageNum == 4){ 
     int nVWidth, nVHeight; 
     nVWidth = self.view.frame.size.width; 
     nVHeight = (self.view.frame.size.height - 243)/2; 
     CGRect frame; 
     frame.origin.x = 27.0f; 
     //  frame.origin.y = 23.0f; 
     frame.origin.y = 65; 
     frame.size  = CGSizeMake(269.5f, 253.5f); 

     NSMutableArray *imgArray = [NSMutableArray array]; 
     IMReviewView *subview = [[IMReviewView alloc] initWithFrame:frame]; 
     subview.delegate = self; 
     subview.photo = [[IMLocalUser localUser] cachedPhotoAtIndex:0]; 
     UIImage *img1 = [[UIImage alloc] init]; 
     img1 = subview.photo.image; 
     [imgArray addObject:img1]; 

     subview.photo = [[IMLocalUser localUser] cachedPhotoAtIndex:1]; 
     UIImage *img2 = [[UIImage alloc] init]; 
     img2 = subview.photo.image; 
     [imgArray addObject:img2]; 

     subview.photo = [[IMLocalUser localUser] cachedPhotoAtIndex:2]; 
     UIImage *img3 = [[UIImage alloc] init]; 
     img3 = subview.photo.image; 
     [imgArray addObject:img3]; 

     subview.photo = [[IMLocalUser localUser] cachedPhotoAtIndex:3]; 
     UIImage *img4 = [[UIImage alloc] init]; 
     img4 = subview.photo.image; 
     [imgArray addObject:img4]; 

     subview.photo = [[IMLocalUser localUser] cachedPhotoAtIndex:4]; 
     UIImage *img5 = [[UIImage alloc] init]; 
     img5 = subview.photo.image; 
     [imgArray addObject:img5]; 

     subview.photo = [[IMLocalUser localUser] cachedPhotoAtIndex:5]; 
     UIImage *img6 = [[UIImage alloc] init]; 
     img6 = subview.photo.image; 
     [imgArray addObject:img6]; 

     subview.photo = [[IMLocalUser localUser] cachedPhotoAtIndex:6]; 
     UIImage *img7 = [[UIImage alloc] init]; 
     img7 = subview.photo.image; 
     [imgArray addObject:img7]; 

     subview.photo = [[IMLocalUser localUser] cachedPhotoAtIndex:7]; 
     UIImage *img8 = [[UIImage alloc] init]; 
     img8 = subview.photo.image; 
     [imgArray addObject:img8]; 

     subview.photo = [[IMLocalUser localUser] cachedPhotoAtIndex:8]; 
     UIImage *img9 = [[UIImage alloc] init]; 
     img9 = subview.photo.image; 
     [imgArray addObject:img9]; 

     subview.photo = [[IMLocalUser localUser] cachedPhotoAtIndex:9]; 
     UIImage *img10 = [[UIImage alloc] init]; 
     img10 = subview.photo.image; 
     [imgArray addObject:img10]; 

     subview.photo = [[IMLocalUser localUser] cachedPhotoAtIndex:10]; 
     UIImage *img11 = [[UIImage alloc] init]; 
     img11 = subview.photo.image; 
     [imgArray addObject:img11]; 

     subview.photo = [[IMLocalUser localUser] cachedPhotoAtIndex:11]; 
     UIImage *img12 = [[UIImage alloc] init]; 
     img12 = subview.photo.image; 
     [imgArray addObject:img12]; 

     subview.photo = [[IMLocalUser localUser] cachedPhotoAtIndex:12]; 
     UIImage *img13 = [[UIImage alloc] init]; 
     img13 = subview.photo.image; 
     [imgArray addObject:img13]; 

     subview.photo = [[IMLocalUser localUser] cachedPhotoAtIndex:13]; 
     UIImage *img14 = [[UIImage alloc] init]; 
     img14 = subview.photo.image; 
     [imgArray addObject:img14]; 

     subview.photo = [[IMLocalUser localUser] cachedPhotoAtIndex:14]; 
     UIImage *img15 = [[UIImage alloc] init]; 
     img15 = subview.photo.image; 
     [imgArray addObject:img15]; 

     subview.photo = [[IMLocalUser localUser] cachedPhotoAtIndex:15]; 
     UIImage *img16 = [[UIImage alloc] init]; 
     img16 = subview.photo.image; 
     [imgArray addObject:img16]; 

답변

2

(따라서 급격한 엔딩 파일 트림했다). 당신이 subview.photo.image에서 img1를 얻을 수 있기 때문에이 세 가지 중 하나를 의미

  1. subview.photo.imagenil입니다.
  2. subview.photonil입니다.
  3. subviewnil입니다.

방금 ​​subview을 생성 했으므로 아마 # 3이 아닙니다. 당신이에서 subview.photo를 얻을 수 있기 때문에 :

[[IMLocalUser localUser] cachedPhotoAtIndex:0]; 

이이 nil이 아닌 값을 반환하는지 확인해야합니다. 0이 아닌 경우 image 속성이 nil이 아닌지 확인하십시오.

사이드 참고 :

이 두 라인 :

UIImage *img1 = [[UIImage alloc] init]; 
img1 = subview.photo.image; 

이 낭비 UIImage을 만들 수 있습니다. 그냥하세요 :

UIImage *img1 = subview.photo.image; 
+0

이상한 점은 때로는 괜찮습니다. 그리고 다른 것들은 IMG4에서 충돌 할 것입니다. – danielsteel

관련 문제