Ive got the following code:
Trying to debug it for a while. Can’t figure it out.
[self.vManager vendorsNearLocation:userLocation block:^(NSArray *vendors, NSError *error)
{
self.vManager.vendors_array = [NSArray arrayWithArray:vendors];
NSLog(@"Vendors array was %d long", [self.vManager.vendors_array count]);
if(vendors && [vendors count])
{
for (id v in vendors)
{
Vendor *aVendor = [[Vendor alloc] initWithAttributes:v];
[self.mapView addAnnotation:aVendor];
[self.vManager.vendor_dict setObject:aVendor
forKey:[aVendor name]];
I was hoping to set the values of the dictionary in that loop. But dictionary is always empty. No errors or warnings, nothing gets set Yet the array has values and my map shows all the vendors. By the way the vManager is a Singleton and Dictionary is being initialized in the viewDidLoad method of the caller
Is there something that Im doing thats obviously wrong?
I think you need to initialize the dictionary in the SINGLETON class itself. I tried the same thing yesterday and it worked.
Just make a function and initialize the dictionary there and call that function before making use of that dictionary.
It will surely work.