Last active
October 13, 2015 04:18
-
-
Save imrekel/4138773 to your computer and use it in GitHub Desktop.
bme-mobilszoftverek - MeetWorld
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)downloadUsers | |
{ | |
NSURLSessionConfiguration* sessionConfig = [NSURLSessionConfiguration defaultSessionConfiguration]; | |
NSURLSession* session = [NSURLSession sessionWithConfiguration:sessionConfig delegate:nil delegateQueue:[NSOperationQueue mainQueue]]; | |
NSURL* url = [NSURL URLWithString: | |
@"http://atleast.aut.bme.hu/mobilszoftverek/meetworld/users"]; | |
[[session dataTaskWithURL: url | |
completionHandler:^(NSData *data, NSURLResponse *response, | |
NSError *error) { | |
NSLog(@"Data received:\n%@\n", | |
[[NSString alloc] initWithData: data | |
encoding: NSUTF8StringEncoding]); | |
}] resume]; | |
for (id<UserManagerObserver> observer in self.observers) | |
{ | |
[observer usersDidUpdate]; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)downloadUsers | |
{ | |
NSDictionary* user1 = @{@"id": @"Sanyi", | |
@"status": @"Szétverem a Mac Mini-t"}; | |
NSDictionary* user2 = @{@"id": @"Panni", | |
@"status": @"Okosodom"}; | |
[self.users addObject:user1]; | |
[self.users addObject:user2]; | |
for (id<UserManagerObserver> observer in self.observers) | |
{ | |
[observer usersDidUpdate]; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)handleLongPress:(UILongPressGestureRecognizer *)recognizer | |
{ | |
if (recognizer.state == UIGestureRecognizerStateBegan) | |
{ | |
UIStoryboard* sb = | |
[UIStoryboard storyboardWithName:@"MainStoryboard" | |
bundle:[NSBundle mainBundle]]; | |
UINavigationController* navigationController = | |
[sb instantiateViewControllerWithIdentifier: | |
@"UpdateUserNavigationController"]; | |
UpdateUserViewController* updateUserVC = navigationController.viewControllers[0]; | |
CGPoint touchPoint = [recognizer locationInView:self.mapView]; | |
updateUserVC.coordinate = [self.mapView convertPoint:touchPoint | |
toCoordinateFromView:self.mapView]; | |
[self presentViewController:navigationController animated:YES completion:nil]; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath | |
{ | |
UITableViewCell *cell = [tableView | |
dequeueReusableCellWithIdentifier:@"UserStatusCell"]; | |
NSArray* users = [UserManager sharedUserManager].users; | |
NSDictionary* user = users[indexPath.row]; | |
cell.textLabel.text = user[@"id"]; | |
cell.detailTextLabel.text = user[@"status"]; | |
return cell; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)usersDidUpdate | |
{ | |
NSArray* users = [UserManager sharedUserManager].users; | |
[self.mapView removeAnnotations:self.mapView.annotations]; | |
for (NSDictionary* user in users) | |
{ | |
UserAnnotation* annotation = [[UserAnnotation alloc] init]; | |
annotation.title = user[@"id"]; | |
annotation.subtitle = user[@"status"]; | |
CLLocationCoordinate2D coord; | |
coord.latitude = [user[@"lat"] doubleValue]; | |
coord.longitude = [user[@"lon"] doubleValue]; | |
annotation.coordinate = coord; | |
[self.mapView addAnnotation:annotation]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment