그처럼 내 코드에 NSUInteger 속성에 액세스 몇 가지 문제했습니다 :액세스
MyController.h
@interface MyController : UIViewController
@property (retain, nonatomic) NSArray *updatesArray;
@property (nonatomic) NSUInteger madeUpdatesCounter;
@property (nonatomic) NSUInteger allUpdatesCounter;
@end
MyController.m
@implementation MyController
@synthesize updatesArray;
@synthesize madeUpdatesCounter;
@synthesize allUpdatesCounter;
- (void)viewDidLoad
{
....
madeUpdatesCounter = 0;
allUpdatesCounter = [updatesArray count];
....
// Register for progress notifications
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(makeProgressChange)
name:@"MadeOneUpdateNotification"
object:nil];
}
- (void)makeProgressChange
{
madeUpdatesCounter++;
NSLog(@"Update progress: %d/%d", madeUpdatesCounter, allUpdatesCounter);
}
@end
I을 NSOperationQueue에 추가하여 NSInvocationOperation으로 내 업데이 트를 proessing. notifocation를 수신 한 번만 실행하고 로그에이 같은가 someting를 참조하고, 위의 코드를 실행 한 후
[[NSNotificationCenter defaultCenter] postNotificationName:@"MadeOneUpdateNotification" object:nil];
: 하나의 업데이트 작업의 끝에서 나는 통지를 보내고있다
업데이트 진행 : 1/3
내가 변경할 때 라인 :
allUpdatesCounter = [updatesArray count];
에
는 모든 작품을 좋아, 나는 로그에 참조하십시오 업데이트 진행 상황을 : 1/3 업데이트 진행 : 2/3 업데이트 진행 :보기를로드하기 전에 3/3
변수 updatedArray이 초기화됩니다. 이런 방식으로 이루어집니다 :
MyController *doUpdatesVC = [self.storyboard instantiateViewControllerWithIdentifier:@"MyController"];
doUpdatesVC.updatesArray = updatesArray;
[self presentViewController:doUpdatesVC animated:YES completion:nil];
내 코드에서 내가 잘못하고있는 것에 대한 조언이나 조언이 있습니까?
updatesArray를 할당/초기화 했습니까? –
예, 했어요. 이 코드 줄을 예제에서 제외했습니다. – Grzegorz
* updatesArray *가 할당되기 전에보기가로드되는지 확인 하시겠습니까? –