나는 이렇게 할 수 있다고 생각합니다.
// Create an array to store the properties
NSMutableArray *viewProperties = [NSMutableArray array];
// Loop through all the views
for (UIView *view in views) {
// Create a dictionary for each view
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
// Store the properties in the dictionary
[dict setValue:NSStringFromCGRect(view.frame) forKey:@"ViewFrame"];
...
// Add the dictionary to the array
[viewProperties addObject:dict];
}
// Finally add the array to persistence
[userDefaults setValue:viewProperties forKey:@"ViewProperties"];
나중에 지속성에서 배열을 가져온 다음 속성을 사용하여보기를 만들 수 있습니다.
NSMutableArray *viewProperties = [userDefaults valueForKey:@"ViewProperties"];
for (NSDictionary *dict in viewProperties) {
UIView *view = [[UIView alloc] init];
NSString *frameAsString = [dict valueForKey:@"ViewFrame"];
view.frame = CGRectFromString(frameAsString);
// Get other properties from dictionary and set it to view
}
헤이 Emptystack의이 응답을 주셔서 감사합니다,하지만 내 요구 사항은 사용자가 자신의 작업을 완료하면 그가, 2 그리기, 그는 다시 다른 새 도면을하고 (1 그리기 저장할 수 있습니다 그의 모든 drawings.Then을 저장 3 그리기 수있다 ....). 마지막으로 그가 원하는 경우 splitview 컨트롤러에서 모든 저축을 볼 수 있으며 원하는 경우 기존 도면을 편집하고 저장할 수 있습니다. – user930195
요즘 스위프트처럼이게 어떻게 생겼을까요? – Heki