Last active
August 29, 2015 14:04
-
-
Save funkyboy/5bc3d8edf9dea130fb3c to your computer and use it in GitHub Desktop.
This file contains 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
BAAClient *c = [BAAClient sharedClient]; | |
[c authenticateUser:@"aaa" password:@"aaa" completion:^(BOOL success, NSError *error) { | |
if (success) { | |
SMTest *test = [[SMTest alloc] init]; | |
test.latitude = 45.2769564; | |
test.longitude = 10.879298; | |
[test saveObjectWithCompletion:^(SMTest *object, NSError *error) { | |
if (error == nil) { | |
NSLog(@"coordinates saved on server %f, %f", object.coordinate.latitude,object.coordinate.longitude); | |
} | |
}]; | |
} else { | |
NSLog(@"err %@", error); | |
} | |
}]; |
This file contains 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
NSDictionary *parameters = @{@"where" : @"distance (latitude,longitude,45.2769564,10.879298) <= 10"}; | |
[SMTest getObjectsWithParams:parameters | |
completion:^(NSArray *places, NSError *error) { | |
if (error == nil) { | |
NSLog(@"Places are %@", places); | |
} else { | |
// deal with error | |
} | |
}]; |
This file contains 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
#import "BAAObject.h" | |
#import <CoreLocation/CoreLocation.h> | |
@interface SMTest : BAAObject | |
@property (nonatomic, assign) NSInteger myInteger; | |
@property (nonatomic, assign) double latitude; | |
@property (nonatomic, assign) double longitude; | |
- (CLLocationCoordinate2D)coordinate; | |
@end |
This file contains 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
#import "SMTest.h" | |
@implementation SMTest | |
- (instancetype)initWithDictionary:(NSDictionary *)dictionary { | |
self = [super initWithDictionary:dictionary]; | |
if (self) { | |
_myInteger = [dictionary[@"myInteger"] integerValue]; | |
_latitude = [dictionary[@"latitude"] doubleValue]; | |
_longitude = [dictionary[@"longitude"] doubleValue]; | |
} | |
return self; | |
} | |
-(NSString *)collectionName { | |
return @"document/test"; | |
} | |
- (CLLocationCoordinate2D) coordinate { | |
CLLocationCoordinate2D myCoordinate; | |
myCoordinate.latitude = _latitude; | |
myCoordinate.longitude = _longitude; | |
return myCoordinate; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment