Global variable is not working correctly <p>In my view controller's main file, I created a property for an NSArray object named <code>finalStringsArray</code>: </p> <p><code>@property (strong, nonatomic) NSArray *finalStringsArray;</code></p> <p>Then in viewDidLoad, I make sure to initialize the object:</p> <pre><code>self.finalStringsArray = [[NSArray alloc]init]; </code></pre> <p>Further down the viewDidLoad method implementation, I query my server for data, get rid of some of the extra junk that the server sends me like blank space, and then I place my perfect strings inside of my <code>finalStringsArray</code> array:</p> <pre><code>[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) { if (!error) { NSString *parseString = [[NSString alloc]initWithFormat:@"%@", objects]; NSString *cURL=[self stringBetweenString:@"=" andString:@")" withstring:parseString]; NSString *newString = [cURL stringByReplacingOccurrencesOfString:@" " withString:@""]; NSString *newString2 = [newString stringByReplacingOccurrencesOfString:@"(" withString:@""]; NSString *newString3 = [newString2 stringByReplacingOccurrencesOfString:@"\\n" withString:@""]; _finalStringsArray = [newString3 componentsSeparatedByString:@","]; int index; for(index = 0; index &lt; _finalStringsArray.count; index++) { NSString *string = [[NSString alloc]init]; string = _finalStringsArray[index]; NSLog(@"Count: %d", _finalStringsArray.count); } NSLog(@"Count: %d", _finalStringsArray.count); } } ];} </code></pre> <p>All that matters in the above code is this statement: <code>_finalStringsArray = [newString3 componentsSeparatedByString:@","];</code></p> <p>This adds my finalized strings to my <code>_finalStringsArray</code> array object. You will notice that I am NSLogging the count property of my array: <code>NSLog(@"Count: %d", _finalStringsArray.count);</code></p> <p>When I perform these NSLogs, they always NSLog with the correct count of 2.</p> <p>Here's my problem though. Further down, I have a method implementation that needs to use the count property of <code>_finalStringsArray</code> as well. But for some reason, it always NSLogs as "0" and I can't figure out why.</p> <p>Below are the 3 method implementations that are below my viewDidLoad. I need to be able to access the count property of <code>_finalStringsArray</code> in the method implementation for <code>-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section</code>:</p> <pre><code>- (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. NSLog(@"all good string count3: %d", _finalParseStrings.count); } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1 ; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { NSLog(@"all good string count5: %d", [self.finalStringsArray count]); return [self.finalStringsArray count]; } </code></pre>