사진을 찍을 수있는 뷰가있는 앱을 개발 중입니다.iPhone : 강한 물건을 파괴하는 메모리 경고?
저는 최근에 아주 이상한 행동에 직면했습니다. 여기에 제 코드가 있습니다.
@interface ViewControllerPhotos : UIViewController
@property (strong) NSString* _albumID;
@end
@implementation ViewControllerPhotos
@synthesize _albumID;
- (void)didReceiveMemoryWarning
{
return;
// commented or not : give the same issue
// [super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self.navigationItem setHidesBackButton:YES];
self._albumID = [Tools generateUUID];
NSLog(@"new photoset : local UUID \"%@\"", self._photoSetLocalID);
}
@end
내 문제는 : 메모리 경고가있는 경우, _albumID
에 저장된 UID 그래서 내 앨범이 두 고장 잊고 다시 생성됩니다. 왜 ? strong
키워드가 현재 값을 유지할 수 있어야합니까?
viewDidload
가 다시 호출 되었기 때문입니까? 만약 그렇다면 우리는 적절한 초기화를 위해 처음으로 뷰를로드하는 방법을 알고 있습니까? 그 방법은 그것을 위해 고안된 것 같았다.
개체는 기본적으로 강하므로 여기서는 strong 키워드를 사용하지 않습니다. 앨범에 대한 앨범 ID를 파일에 쓰고 메모리 경고를 받으면 검색하십시오. – Dustin
'if (! self._albumID || [self._albumID isEqualToString : @ ""]) self._albumID = [Tools generateUUID];'viewDidLoad'에서 해결했습니다! – dvkch