I have a a block for enumeration and some properties in an .h file and want to access them inside my block how can i do that?
here is my code:
.h file
@property (nonatomic,retain) NSMutableArray *productsArray;
.m file
NSArray *products = [jsonDict objectForKey:@"products"];
[products enumerateObjectsUsingBlock:^(id obj,NSUInteger idx, BOOL *stop){
//getting the products links on productsArray
[self.productsArray addObject:[obj objectForKey:@"thumbnail_url"]];
}];
but my _productsArray is empty after the block execution
i’ve studied about _block variable name but what about properties?
i just want to get an array after the enumeration with some particular items!
Is that a good practice?
What are your suggestions?
You need to initalise the productsArray at some point before adding objects to it: