I am new to Objective-C from iOS 8, so knowing a little about ARC, and my code is under ARC.
Say I have a class UserModel has properties like NSArray and NSString. I have initWithDataSource:data to alloc init a UserModel.
Is it safe to set a property inside block, from memory perspetive? I feel my code will cause any retain cycle. want to know should I use something like weak self or other things to set property?
//in HomeViewController.m
@interface HomeViewController() <UICollectionViewDataSource>
@property (strong, nonatomic) IBOutlet UILabel *HomeLabel;
@property (strong, nonatomic) IBOutlet UICollectionView *ProjectCollectionView;
@property (strong, nonatomic) UserModel * HomeViewUserModel;
@end
/**
* fetch latest projects from remote side
*/
- (void) fetchUserModelFromRemote {
[MySharedInstance getProjectDataOnSuccess:^(id result) {
NSDictionary *data = result[@"data"];
self.HomeViewUserModel = [[UserModel alloc] initWithDataSource:data];
[[NSNotificationCenter defaultCenter] postNotificationName:@"alertCountUpdate" object:self userInfo:@{@"count": (NSNumber *)data[@"unread"]}];
}onFailure:^(id error) {}];
[MyCache cacheProjectListWithData:self.HomeViewUserModel];
}