So i am wondering how to go about retrieving Parse coordinates and drawing a shape using MapBox.
I can retrieve the coordinates and plot them individually (using PARSE) on a map fine:
PFQuery *locationQuery = [PFQuery queryWithClassName:#"Location"];
[locationQuery whereKeyExists:#"location"];
locationQuery.cachePolicy = kPFCachePolicyNetworkElseCache;
[locationQuery findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
// The find succeeded.
NSLog(#"Successfully retrieved %lu scores.", (unsigned long)objects.count);
NSLog(#"Object is %# and %#", [objects objectAtIndex:0],[objects objectAtIndex:1]);
for (PFObject *gp in objects) {
//How to get PFGeoPoint and then a location out of an object
PFGeoPoint *location = [gp objectForKey:#"location"];
NSLog(#"Hi there my name is: %f", location.latitude);
CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(location.latitude, location.longitude);
//This is how to populate the data with a title
NSString *title = [NSString stringWithFormat:#"%#", gp.createdAt];
RMPointAnnotation *annotation3 = [[RMPointAnnotation alloc] initWithMapView:mapView coordinate:coordinate andTitle:title];
[mapView addAnnotation:annotation3];
}
} else {
// Log details of the failure
NSLog(#"Error: %# %#", error, [error userInfo]);
}
}];
Adding a shape to a map (using MapBox) is doable as well:
//Line for streets location arrays, etc MapBox
NSArray *locations = [NSArray arrayWithObjects:[[CLLocation alloc] initWithLatitude:-33.980852 longitude:151.072498],
[[CLLocation alloc] initWithLatitude:-33.981769 longitude:151.072300],
[[CLLocation alloc] initWithLatitude:-33.982018 longitude:151.072257],
[[CLLocation alloc] initWithLatitude:-33.982187 longitude:151.072225], nil, nil];
RMAnnotation *annoation43 = [[RMAnnotation alloc] initWithMapView:mapView coordinate:((CLLocation *)[locations
objectAtIndex:0]).coordinate andTitle:#"Hola biatches!"];
annoation43.userInfo = locations;
[annoation43 setBoundingBoxFromLocations:locations];
[mapView addAnnotation:annoation43];
NSLog(#"It is working Dora!");
-(RMMapLayer *)mapView:(RMMapView *)mapViewer layerForAnnotation:(RMAnnotation *)annotation {
if (annotation.isUserLocationAnnotation)
return nil;
RMShape *shape = [[RMShape alloc] initWithView:mapView];
//Line dashes and colours and widths, etc
shape.lineColor = [UIColor orangeColor];
shape.lineWidth = 4.0;
shape.scaleLineWidth = YES;
shape.scaleLineDash = YES;
shape.lineDashLengths = [NSArray arrayWithObjects:[NSNumber numberWithInt:4], [NSNumber numberWithInt:6], nil];
shape.lineDashPhase = 3.0f;
for (CLLocation *location in (NSArray *)annotation.userInfo)
[shape addLineToCoordinate:location.coordinate];
return shape;
}
I am wondering how i would get MapBox to draw a shape from these coordinates? I have had a few attempts and am getting nowhere so someone with a better mind than i would be greatly appreciated. If you need any more information let me know.
I figured it out - my solution i was attempting was fine - i was initialising the array WITHIN the loop and so it was recreating the array each time and so was overwriting each new coordinate and trying to draw a shape using only one coordinate.
PFQuery *locationQuery2 = [PFQuery queryWithClassName:#"Location"];
[locationQuery2 whereKeyExists:#"location"];
locationQuery2.limit = 4;
locationQuery2.cachePolicy = kPFCachePolicyNetworkElseCache;
[locationQuery2 findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
// The find succeeded.
NSLog(#"Successfully retrieved %lu scores.", (unsigned long)objects.count);
NSLog(#"Object is %# and %#", [objects objectAtIndex:0],[objects objectAtIndex:1]);
NSMutableArray *locations = [[[NSMutableArray alloc] init] mutableCopy];
for (PFObject *gp in objects) {
//How to get PFGeoPoint and then a location out of an object
PFGeoPoint *location = [gp objectForKey:#"location"];
NSLog(#"Hi there my name is not: %f", location.latitude);
CLLocation *coordinate = [[CLLocation alloc] initWithLatitude:location.latitude longitude:location.longitude];
//Line for streets location arrays, etc MapBox
[locations addObject:coordinate];
RMAnnotation *annoation43 = [[RMAnnotation alloc] initWithMapView:mapView coordinate:((CLLocation *)[locations objectAtIndex:0]).coordinate andTitle:#"Hola biatches!"];
annoation43.userInfo = locations;
[annoation43 setBoundingBoxFromLocations:locations];
[mapView addAnnotation:annoation43];
NSLog(#"It is working Dora!");
NSLog(#"Yeah its is: %#", locations);
}
} else {
// Log details of the failure
NSLog(#"Error: %# %#", error, [error userInfo]);
}
}];
Related
I’m using mkmapview in my application it contains multiple polyline overlay and multiple custom annotations, while running the application receiving memory warning oftenly, I struggled a lot
Thanks in advance.
for (int i = 0; i<[latArray count]-1; i++)
{
NSString *lat1 = [latArray objectAtIndex:i];
NSString *longi1 = [longArray objectAtIndex:i];
firstPlace = CLLocationCoordinate2DMake([lat1 doubleValue], [longi1 doubleValue]);
NSString *lat2 = [latArray objectAtIndex:i+1];
NSString *longi2 = [longArray objectAtIndex:i+1];
secPlace = CLLocationCoordinate2DMake([lat2 doubleValue], [longi2 doubleValue]);
[self directionRequest:firstPlace :secPlace index:i];
}
-(void)directionRequest:(CLLocationCoordinate2D )firstCord :(CLLocationCoordinate2D )secCord index:(int)index
{
#try
{
MKPlacemark *source=[[MKPlacemark alloc]initWithCoordinate:firstCord addressDictionary:[NSDictionary dictionaryWithObjectsAndKeys:#"",#"", nil]];
MKMapItem *sourceMapItem=[[MKMapItem alloc]initWithPlacemark:source];
[sourceMapItem setName:#""];
MKPlacemark *destination=[[MKPlacemark alloc]initWithCoordinate:secCord addressDictionary:[NSDictionary dictionaryWithObjectsAndKeys:#"",#"", nil]];
MKMapItem *destinationMapitem=[[MKMapItem alloc]initWithPlacemark:destination];
[destinationMapitem setName:#""];
MKDirectionsRequest *dirRequest=[[MKDirectionsRequest alloc]init];
[dirRequest setSource:sourceMapItem];
[dirRequest setDestination:destinationMapitem];
// dirRequest.requestsAlternateRoutes = YES;
[dirRequest setTransportType:MKDirectionsTransportTypeAutomobile];
MKDirections *direction=[[MKDirections alloc]initWithRequest:dirRequest];
[direction calculateDirectionsWithCompletionHandler:^(MKDirectionsResponse *response, NSError *error)
{
// NSLog(#"response = %#",response);
NSArray *arrRoutes = [response routes];
[arrRoutes enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop)
{
MKRoute *rout = obj;
MKPolyline *line = [rout polyline];
[iMapView addOverlay:line];
}];
}];
}
#catch (NSException *exception)
{
}
}
I have a for loop that goes through an array of tweets I get from the Twitter API. As long as the coordinates for each tweet are not null, an annotation is created with the screen_name from the tweet as the title and the coordinates of the tweet. Each annotation is added to an array and when the loop is finished, the annotations from that array are added to a map view. My issue is that only the first tweet is getting added as an annotation. What am I missing?
STTwitterAPI *twitter = [STTwitterAPI twitterAPIAppOnlyWithConsumerKey:#"key" consumerSecret:#"secret"];
[twitter verifyCredentialsWithSuccessBlock:^(NSString *username) {
[twitter getSearchTweetsWithQuery:#"apple" geocode:geoCode lang:nil locale:nil resultType:#"recent" count:#"10" until:nil sinceID:nil maxID:nil includeEntities:nil callback:nil successBlock:^(NSDictionary *searchMetadata, NSArray *statuses) {
tweetsArray = [NSMutableArray arrayWithArray:statuses];
NSLog(#"tweetsArray: %#", tweetsArray);
for (int i = 0; i < [tweetsArray count]; i++) {
NSDictionary *t = tweetsArray[i];
tweetAnnotation = [[MKPointAnnotation alloc]init];
NSArray *tweetLocation = [[t valueForKey:#"geo"]valueForKey:#"coordinates"];
NSLog(#"Tweet Location: %#", tweetLocation);
if ([tweetLocation isEqual:[NSNull null]]) {
continue;
}
else {
double lat = [[tweetLocation objectAtIndex:0]doubleValue];
double longitude = [[tweetLocation objectAtIndex:1]doubleValue];
locationCoord.latitude = lat;
locationCoord.longitude = longitude;
NSLog(#"Lat: %.8f, Long: %.8f", lat, longitude);
twitterName = [t valueForKeyPath:#"user.screen_name"];
NSLog(#"Twitter name: %#", twitterName);
tweetAnnotation.title = twitterName;
tweetAnnotation.coordinate = locationCoord;
[tweetLocationsArray addObject:tweetAnnotation];
}
}
[tweetMap addAnnotations:tweetLocationsArray];
} errorBlock:^(NSError *error) {
NSLog(#"%#", error.debugDescription);
}];
} errorBlock:^(NSError *error) {
NSLog(#"%#", error.debugDescription);
}];
I need to change the color and in some positions i need to set images for the annotation point. My code only displays red color Annotation please guide me my code is bellow,
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
//MAP VIEW WebService
// NSLog(#"%#",nam2);
NSString *urlMapString=[NSString stringWithFormat:#"http://www.tranzlogix.com/tranzlogix_webservice/map.php?format=json&truckno=%#",nam2];
NSURL *urlMap=[NSURL URLWithString:urlMapString];
NSData *dataMap=[NSData dataWithContentsOfURL:urlMap];
NSError *errorMap;
NSDictionary *jsonMap = [NSJSONSerialization JSONObjectWithData:dataMap options:kNilOptions error:&errorMap]; NSArray *resultsMap = [jsonMap valueForKey:#"posts"];
NSArray *resMap = [resultsMap valueForKey:#"post"];
NSArray *latitudeString=[resMap valueForKey:#"latitude"];
// NSLog(#"%#", latitudeString);
NSString *latOrgstring = [latitudeString objectAtIndex:0];
// NSLog(#"%#", latOrgstring);
double latitude=[latOrgstring doubleValue];
NSArray *longitudeString=[resMap valueForKey:#"longitude"];
// NSLog(#"%#", longitudeString);
NSString *longOrgstring = [longitudeString objectAtIndex:0];
// NSLog(#"%#", longOrgstring);
double longitude=[longOrgstring doubleValue];
// NSLog(#"latdouble: %f", longitude);
//MAP VIEW Point
MKCoordinateRegion myRegion;
//Center
CLLocationCoordinate2D center;
center.latitude=latitude;
center.longitude=longitude;
//Span
MKCoordinateSpan span;
span.latitudeDelta=THE_SPAN;
span.longitudeDelta=THE_SPAN;
myRegion.center=center;
myRegion.span=span;
//Set our mapView
[MapViewC setRegion:myRegion animated:YES];
//Annotation
//1.create coordinate for use with the annotation
CLLocationCoordinate2D wimbLocation;
wimbLocation.latitude=latitude;
wimbLocation.longitude=longitude;
Annotation * myAnnotation= [Annotation alloc];
CLLocation *someLocation=[[CLLocation alloc]initWithLatitude:latitude longitude:longitude];
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
[geocoder reverseGeocodeLocation:someLocation completionHandler:^(NSArray *placemarks, NSError *error) {
NSDictionary *dictionary = [[placemarks objectAtIndex:0] addressDictionary];
// NSLog(#"%#",dictionary);
addressOutlet=[dictionary valueForKey:#"Street"];
// NSLog(#"%#",addressOutlet);
City=[dictionary valueForKey:#"City"];
// NSLog(#"%#",City);
State=[dictionary valueForKey:#"State"];
// NSLog(#"%#",State);
myAnnotation.coordinate=wimbLocation;
if (addressOutlet!=NULL&&City!=NULL)
{
myAnnotation.title=addressOutlet;
myAnnotation.subtitle=[NSString stringWithFormat:#"%#,%#", City, State];
}
else if (addressOutlet==NULL&&City!=NULL)
{
myAnnotation.title=City;
myAnnotation.subtitle=[NSString stringWithFormat:#"%#,%#", City, State];
}
else if (addressOutlet!=NULL&&City==NULL)
{
myAnnotation.title=addressOutlet;
myAnnotation.subtitle=[NSString stringWithFormat:#"%#", State];
}
else if(addressOutlet==NULL&&City==NULL)
{
myAnnotation.title=State;
myAnnotation.subtitle=[NSString stringWithFormat:#"%#",State];
}
[self.MapViewC addAnnotation:myAnnotation];
}];
}
Please guide me i am very new to xcode & objective-c
You need to subclass the MKAnnotationView and override a couple of properties and methods to set an image of your preference. Since thats just too much of a walk through I managed to fish out a blog to help you do that.
I am creating an iOS app using Parse database(asynchronously) to store information that will be used when populating a mapview. I have been trying to figure out what is wrong for a long time and have done plenty of research without any luck. I have, however, found the source of the issue.
In my code, I am querying the parse database in hopes of getting the information I want and then storing the information in a custom pointAnnotation class, which is of type MkPointAnnotation. Each item is stored in an array of pointAnnotations, and once all items in the database have been stored in the array, the annotations are added to MyMapView. --I have tried adding the annotations as they are created, which does not change anything.
The issue I have been having is that randomly, the query will iterate under the for(PFObject *vendor in Vendors) and reach an error, calling NSLog(#"%#", error.debugDescription); which shows (null) in the output log. The amount of objects that return null seems to change each time I run the application, and occasionally it will work as expected. After adding a do while(pointArray.count < query.countObjects), the function will iterate roughly 20-30 times and then will add the correct number of annotations, however, it is extremely inefficient.
Is this an inefficiency within Parse or is there a better way to achieve the expected results?
PFQuery *query = [PFQuery queryWithClassName:#"Vendors"];
[query orderByDescending:#"updatedAt"];
[query findObjectsInBackgroundWithBlock:^(NSArray *vendors, NSError *error){
NSMutableArray *pointArray = [[NSMutableArray alloc] init];
if (!error) {
// The find succeeded.
// Do something with the found objects
do {
pointArray = [[NSMutableArray alloc] init];
for (PFObject *vendor in vendors) {
NSDate *lastUpdated = vendor.updatedAt;
NSDate *today = [NSDate date];
NSDate *newDate = [lastUpdated dateByAddingTimeInterval:86400];
if (today <= newDate) {
PFGeoPoint *point = vendor[#"Location"];
NSString *vendor_ID = vendor[#"Vendor_ID"];
NSMutableArray *FruitList = vendor[#"Fruits"];
NSMutableArray *VeggieList = vendor[#"Veggies"];
NSMutableArray *addressArray = vendor[#"Address"];
NSString *startHr = vendor[#"Start_Time"];
NSString *endHr = vendor[#"End_Time"];
Boolean more = false;
NSString *moreString = vendor[#"And_More"];
if ([moreString isEqual: #"true"]) {
more = true;
}
CLLocationCoordinate2D location;
location.latitude = point.latitude;
location.longitude = point.longitude;
pointAnnotation *newAnnotation = [[pointAnnotation alloc] init];
if ([[[NSUserDefaults standardUserDefaults] objectForKey:#"language"] isEqual:#"ENGLISH"]){
FindCartsLabel.text = #"Find Carts within:";
MilesTextField.text = #"Show All";
milesArray=[[NSArray alloc]initWithObjects:#"Show All", #"1 Mile", #"5 Miles", #"10 Miles", #"20 Miles", nil];
AddressBar.placeholder = ENGLISH_Address;
newAnnotation.title = #"Good. To. Go. Vendor";
newAnnotation.fruits = FruitList;
newAnnotation.veggies = VeggieList;
}else if ([[[NSUserDefaults standardUserDefaults] objectForKey:#"language"] isEqual:#"SPANISH"]){
FindCartsLabel.text = #"Encuentra Carros Dentro:";
newAnnotation.title = #"Good. To. Go. Vendedor";
AddressBar.placeholder = SPANISH_Address;
NSMutableArray *spanishFruitList = [[NSMutableArray alloc]init];
for (NSString *current in FruitList) {
MilesTextField.text = #"Mostrar Todo";
milesArray=[[NSArray alloc]initWithObjects:#"Mostrar Todo", #"1 Milla", #"5 Millas", #"10 Millas", #"20 Millas", nil];
if ([current isEqual:#"Apples"]) {
[spanishFruitList addObject:SPANISH_Apples];
}
if ([current isEqual:#"Bananas"]) {
[spanishFruitList addObject:SPANISH_Bananas];
}
if ([current isEqual:#"Citrus"]) {
[spanishFruitList addObject:SPANISH_Citrus];
}
if ([current isEqual:#"Mangos"]) {
[spanishFruitList addObject:SPANISH_Mangos];
}
if ([current isEqual:#"Strawberries"]) {
[spanishFruitList addObject:SPANISH_Strawberries];
}
if ([current isEqual:#"And More"]) {
[spanishFruitList addObject:SPANISH_More];
}
}
NSMutableArray *spanishVeggieList = [[NSMutableArray alloc]init];
for (NSString *current in VeggieList) {
if ([current isEqual:#"Avocados"]) {
[spanishVeggieList addObject:SPANISH_Avocados];
}
if ([current isEqual:#"Broccoli"]) {
[spanishVeggieList addObject:SPANISH_Broccoli];
}
if ([current isEqual:#"Carrots"]) {
[spanishVeggieList addObject:SPANISH_Carrots];
}
if ([current isEqual:#"Squash"]) {
[spanishVeggieList addObject:SPANISH_Squash];
}
if ([current isEqual:#"Onions"]) {
[spanishVeggieList addObject:SPANISH_Onions];
}
if ([current isEqual:#"Tomatoes"]) {
[spanishVeggieList addObject:SPANISH_Tomatoes];
}
if ([current isEqual:#"And More"]) {
[spanishVeggieList addObject:SPANISH_More];
}
}
newAnnotation.fruits = spanishFruitList;
newAnnotation.veggies = spanishVeggieList;
}
newAnnotation.coordinate = location;
newAnnotation.vendorID = vendor_ID;
newAnnotation.startHour = startHr;
newAnnotation.endHour = endHr;
newAnnotation.loc = point;
newAnnotation.isCustomAddress = false;
//newAnnotation.subtitle = address;
__block NSString *address = [NSString stringWithFormat:#"%# %#, %#, %#, %#",
addressArray[0], addressArray[1],
addressArray[2], addressArray[3],
addressArray[4]];
__block NSString *currAddress = [NSString stringWithFormat:#"%# %#\n"
"%#, %#, %#\n"
"%#\n",
addressArray[0], addressArray[1],
addressArray[2], addressArray[3],
addressArray[4], addressArray[5]];
newAnnotation.subtitle = address;
newAnnotation.addressFormatted = currAddress;
static NSString *identifier = #"MyLocation";
MKPinAnnotationView *currentView = [[MKPinAnnotationView alloc] initWithAnnotation:newAnnotation reuseIdentifier:identifier];
[pointArray addObject:currentView];
} else {
//[self viewDidLoad];
NSLog(#"%#", error.debugDescription);
}
//} ];
}
} while (pointArray.count < query.countObjects);
}
if (pointArray.count == query.countObjects) {
for (MKPinAnnotationView *currentPoint in pointArray) {
[self.MyMapView addAnnotation:currentPoint.annotation];
}
}
}];
Thanks in advance for the help. I do not really understand why this code would not complete after only one iteration.
The NSLog(#"%#", error.debugDescription); doesn't look like it's in the right place. It's in an else block that is associated with the if (today <= newDate) which is inside a block of code that is only executed if error is null which is why it says null in the log (when what it really means is "today > newDate"). – Anna
I am showing an several images using an UIScrollView. however I would want it to refresh automatically.
I want to refresh it every time I show the view controller.
Using my code I have to push the refresh button every time which is just nonsense.
Here is the code : How can i do this ?
- (IBAction)refresh:(id)sender
{
NSLog(#"Showing Refresh HUD");
refreshHUD = [[MBProgressHUD alloc] initWithView:self.view];
[self.view addSubview:refreshHUD];
// Register for HUD callbacks so we can remove it from the window at the right time
refreshHUD.delegate = self;
// Show the HUD while the provided method executes in a new thread
[refreshHUD show:YES];
PFQuery *query = [PFQuery queryWithClassName:#"TPhoto"];
PFUser *user = [PFUser currentUser];
[query whereKey:#"user" equalTo:user];
[query orderByAscending:#"createdAt"];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
// The find succeeded.
if (refreshHUD) {
[refreshHUD hide:YES];
refreshHUD = [[MBProgressHUD alloc] initWithView:self.view];
[self.view addSubview:refreshHUD];
// The sample image is based on the work by http://www.pixelpressicons.com, http://creativecommons.org/licenses/by/2.5/ca/
// Make the customViews 37 by 37 pixels for best results (those are the bounds of the build-in progress indicators)
refreshHUD.customView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"37x-Checkmark.png"]];
// Set custom view mode
refreshHUD.mode = MBProgressHUDModeCustomView;
refreshHUD.delegate = self;
}
NSLog(#"Successfully retrieved %d photos.", objects.count);
// Retrieve existing objectIDs
NSMutableArray *oldCompareObjectIDArray = [NSMutableArray array];
for (UIView *view in [photoScrollView subviews]) {
if ([view isKindOfClass:[UIButton class]]) {
UIButton *eachButton = (UIButton *)view;
[oldCompareObjectIDArray addObject:[eachButton titleForState:UIControlStateReserved]];
}
}
NSMutableArray *oldCompareObjectIDArray2 = [NSMutableArray arrayWithArray:oldCompareObjectIDArray];
// If there are photos, we start extracting the data
// Save a list of object IDs while extracting this data
NSMutableArray *newObjectIDArray = [NSMutableArray array];
if (objects.count > 0) {
for (PFObject *eachObject in objects) {
[newObjectIDArray addObject:[eachObject objectId]];
}
}
// Compare the old and new object IDs
NSMutableArray *newCompareObjectIDArray = [NSMutableArray arrayWithArray:newObjectIDArray];
NSMutableArray *newCompareObjectIDArray2 = [NSMutableArray arrayWithArray:newObjectIDArray];
if (oldCompareObjectIDArray.count > 0) {
// New objects
[newCompareObjectIDArray removeObjectsInArray:oldCompareObjectIDArray];
// Remove old objects if you delete them using the web browser
[oldCompareObjectIDArray removeObjectsInArray:newCompareObjectIDArray2];
if (oldCompareObjectIDArray.count > 0) {
// Check the position in the objectIDArray and remove
NSMutableArray *listOfToRemove = [[NSMutableArray alloc] init];
for (NSString *objectID in oldCompareObjectIDArray){
int i = 0;
for (NSString *oldObjectID in oldCompareObjectIDArray2){
if ([objectID isEqualToString:oldObjectID]) {
// Make list of all that you want to remove and remove at the end
[listOfToRemove addObject:[NSNumber numberWithInt:i]];
}
i++;
}
}
// Remove from the back
NSSortDescriptor *highestToLowest = [NSSortDescriptor sortDescriptorWithKey:#"self" ascending:NO];
[listOfToRemove sortUsingDescriptors:[NSArray arrayWithObject:highestToLowest]];
for (NSNumber *index in listOfToRemove){
[allImages removeObjectAtIndex:[index intValue]];
}
}
}
// Add new objects
for (NSString *objectID in newCompareObjectIDArray){
for (PFObject *eachObject in objects){
if ([[eachObject objectId] isEqualToString:objectID]) {
NSMutableArray *selectedPhotoArray = [[NSMutableArray alloc] init];
[selectedPhotoArray addObject:eachObject];
if (selectedPhotoArray.count > 0) {
[allImages addObjectsFromArray:selectedPhotoArray];
}
}
}
}
// Remove and add from objects before this
[self setUpImages:allImages];
} else {
[refreshHUD hide:YES];
// Log details of the failure
NSLog(#"Error: %# %#", error, [error userInfo]);
}
}];
}
Call the refresh method from viewDidAppear in your view controller.
However, if that can happen often, you should consider keeping the images in a local cache and only refresh them if there is something new to show on the server.