Initial implementation of Mac example application
This commit is contained in:
parent
4d4847d5d8
commit
f3029262df
@ -10,6 +10,11 @@
|
||||
F87A159F1444926300318955 /* AFURLConnectionOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F87A159E1444926300318955 /* AFURLConnectionOperation.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||
F87A15A21444926A00318955 /* AFXMLRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F87A15A11444926900318955 /* AFXMLRequestOperation.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||
F87A15A51444927300318955 /* AFPropertyListRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F87A15A41444927300318955 /* AFPropertyListRequestOperation.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||
F87A15CD1444A30800318955 /* AFGowallaAPIClient.m in Sources */ = {isa = PBXBuildFile; fileRef = F87A15C61444A30800318955 /* AFGowallaAPIClient.m */; };
|
||||
F87A15CE1444A30800318955 /* NearbySpotsController.m in Sources */ = {isa = PBXBuildFile; fileRef = F87A15C91444A30800318955 /* NearbySpotsController.m */; };
|
||||
F87A15CF1444A30800318955 /* Spot.m in Sources */ = {isa = PBXBuildFile; fileRef = F87A15CC1444A30800318955 /* Spot.m */; };
|
||||
F87A15D11444A3EB00318955 /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F87A15D01444A3EB00318955 /* CoreLocation.framework */; };
|
||||
F87A15DD1444A86600318955 /* placeholder-stamp.png in Resources */ = {isa = PBXBuildFile; fileRef = F87A15DB1444A86600318955 /* placeholder-stamp.png */; };
|
||||
F897DE78142CFEDC000DDD35 /* AFHTTPClient.m in Sources */ = {isa = PBXBuildFile; fileRef = F897DE6A142CFEDC000DDD35 /* AFHTTPClient.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||
F897DE79142CFEDC000DDD35 /* AFHTTPRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F897DE6C142CFEDC000DDD35 /* AFHTTPRequestOperation.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||
F897DE7A142CFEDC000DDD35 /* AFImageCache.m in Sources */ = {isa = PBXBuildFile; fileRef = F897DE6E142CFEDC000DDD35 /* AFImageCache.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||
@ -32,6 +37,14 @@
|
||||
F87A15A11444926900318955 /* AFXMLRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFXMLRequestOperation.m; sourceTree = "<group>"; };
|
||||
F87A15A31444927300318955 /* AFPropertyListRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFPropertyListRequestOperation.h; sourceTree = "<group>"; };
|
||||
F87A15A41444927300318955 /* AFPropertyListRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFPropertyListRequestOperation.m; sourceTree = "<group>"; };
|
||||
F87A15C51444A30800318955 /* AFGowallaAPIClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFGowallaAPIClient.h; sourceTree = "<group>"; };
|
||||
F87A15C61444A30800318955 /* AFGowallaAPIClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFGowallaAPIClient.m; sourceTree = "<group>"; };
|
||||
F87A15C81444A30800318955 /* NearbySpotsController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NearbySpotsController.h; sourceTree = "<group>"; };
|
||||
F87A15C91444A30800318955 /* NearbySpotsController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NearbySpotsController.m; sourceTree = "<group>"; };
|
||||
F87A15CB1444A30800318955 /* Spot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Spot.h; sourceTree = "<group>"; };
|
||||
F87A15CC1444A30800318955 /* Spot.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Spot.m; sourceTree = "<group>"; };
|
||||
F87A15D01444A3EB00318955 /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; };
|
||||
F87A15DB1444A86600318955 /* placeholder-stamp.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "placeholder-stamp.png"; sourceTree = "<group>"; };
|
||||
F897DE69142CFEDC000DDD35 /* AFHTTPClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFHTTPClient.h; sourceTree = "<group>"; };
|
||||
F897DE6A142CFEDC000DDD35 /* AFHTTPClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFHTTPClient.m; sourceTree = "<group>"; };
|
||||
F897DE6B142CFEDC000DDD35 /* AFHTTPRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFHTTPRequestOperation.h; sourceTree = "<group>"; };
|
||||
@ -68,6 +81,7 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
F87A15D11444A3EB00318955 /* CoreLocation.framework in Frameworks */,
|
||||
F8CEEB6F142CEC6E00247B03 /* Cocoa.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@ -75,6 +89,43 @@
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
F87A15C41444A30800318955 /* Classes */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F87A15C51444A30800318955 /* AFGowallaAPIClient.h */,
|
||||
F87A15C61444A30800318955 /* AFGowallaAPIClient.m */,
|
||||
F87A15C71444A30800318955 /* Controllers */,
|
||||
F87A15CA1444A30800318955 /* Models */,
|
||||
);
|
||||
path = Classes;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F87A15C71444A30800318955 /* Controllers */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F87A15C81444A30800318955 /* NearbySpotsController.h */,
|
||||
F87A15C91444A30800318955 /* NearbySpotsController.m */,
|
||||
);
|
||||
path = Controllers;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F87A15CA1444A30800318955 /* Models */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F87A15CB1444A30800318955 /* Spot.h */,
|
||||
F87A15CC1444A30800318955 /* Spot.m */,
|
||||
);
|
||||
path = Models;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F87A15DA1444A86600318955 /* Images */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F87A15DB1444A86600318955 /* placeholder-stamp.png */,
|
||||
);
|
||||
path = Images;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F897DE68142CFEDC000DDD35 /* AFNetworking */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@ -104,37 +155,6 @@
|
||||
path = ../../AFNetworking;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F8A27AB4142CFE1300F5E0D6 /* Classes */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F8A27AB5142CFE1300F5E0D6 /* Controllers */,
|
||||
F8A27AB6142CFE1300F5E0D6 /* Models */,
|
||||
F8A27AB7142CFE1300F5E0D6 /* Views */,
|
||||
);
|
||||
path = Classes;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F8A27AB5142CFE1300F5E0D6 /* Controllers */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
);
|
||||
path = Controllers;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F8A27AB6142CFE1300F5E0D6 /* Models */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
);
|
||||
path = Models;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F8A27AB7142CFE1300F5E0D6 /* Views */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
);
|
||||
path = Views;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F8A27ABD142CFE1300F5E0D6 /* Vendor */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@ -163,6 +183,7 @@
|
||||
F8A27AC5142CFE1300F5E0D6 /* AppDelegate.h */,
|
||||
F8A27AB9142CFE1300F5E0D6 /* Credits.rtf */,
|
||||
F8A27ABB142CFE1300F5E0D6 /* MainMenu.xib */,
|
||||
F87A15DA1444A86600318955 /* Images */,
|
||||
);
|
||||
name = "Supporting Files";
|
||||
sourceTree = "<group>";
|
||||
@ -170,7 +191,7 @@
|
||||
F8CEEB5F142CEC6E00247B03 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F8A27AB4142CFE1300F5E0D6 /* Classes */,
|
||||
F87A15C41444A30800318955 /* Classes */,
|
||||
F8A27ACD142CFE3000F5E0D6 /* Supporting Files */,
|
||||
F8A27ABD142CFE1300F5E0D6 /* Vendor */,
|
||||
F8CEEB6D142CEC6E00247B03 /* Frameworks */,
|
||||
@ -189,6 +210,7 @@
|
||||
F8CEEB6D142CEC6E00247B03 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F87A15D01444A3EB00318955 /* CoreLocation.framework */,
|
||||
F8CEEB6E142CEC6E00247B03 /* Cocoa.framework */,
|
||||
F8CEEB70142CEC6E00247B03 /* Other Frameworks */,
|
||||
);
|
||||
@ -258,6 +280,7 @@
|
||||
files = (
|
||||
F8A27AC9142CFE1300F5E0D6 /* Credits.rtf in Resources */,
|
||||
F8A27ACA142CFE1300F5E0D6 /* MainMenu.xib in Resources */,
|
||||
F87A15DD1444A86600318955 /* placeholder-stamp.png in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@ -281,6 +304,9 @@
|
||||
F87A159F1444926300318955 /* AFURLConnectionOperation.m in Sources */,
|
||||
F87A15A21444926A00318955 /* AFXMLRequestOperation.m in Sources */,
|
||||
F87A15A51444927300318955 /* AFPropertyListRequestOperation.m in Sources */,
|
||||
F87A15CD1444A30800318955 /* AFGowallaAPIClient.m in Sources */,
|
||||
F87A15CE1444A30800318955 /* NearbySpotsController.m in Sources */,
|
||||
F87A15CF1444A30800318955 /* Spot.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
31
Mac Example/Classes/AFGowallaAPIClient.h
Normal file
31
Mac Example/Classes/AFGowallaAPIClient.h
Normal file
@ -0,0 +1,31 @@
|
||||
// AFGowallaAPI.h
|
||||
//
|
||||
// Copyright (c) 2011 Gowalla (http://gowalla.com/)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "AFHTTPClient.h"
|
||||
|
||||
extern NSString * const kAFGowallaClientID;
|
||||
extern NSString * const kAFGowallaBaseURLString;
|
||||
|
||||
@interface AFGowallaAPIClient : AFHTTPClient
|
||||
+ (AFGowallaAPIClient *)sharedClient;
|
||||
@end
|
||||
61
Mac Example/Classes/AFGowallaAPIClient.m
Normal file
61
Mac Example/Classes/AFGowallaAPIClient.m
Normal file
@ -0,0 +1,61 @@
|
||||
// AFGowallaAPI.m
|
||||
//
|
||||
// Copyright (c) 2011 Gowalla (http://gowalla.com/)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#import "AFGowallaAPIClient.h"
|
||||
|
||||
#import "AFJSONRequestOperation.h"
|
||||
|
||||
// Replace this with your own API Key, available at http://api.gowalla.com/api/keys/
|
||||
NSString * const kAFGowallaClientID = @"e7ccb7d3d2414eb2af4663fc91eb2793";
|
||||
|
||||
NSString * const kAFGowallaBaseURLString = @"https://api.gowalla.com/";
|
||||
|
||||
@implementation AFGowallaAPIClient
|
||||
|
||||
+ (AFGowallaAPIClient *)sharedClient {
|
||||
static AFGowallaAPIClient *_sharedClient = nil;
|
||||
static dispatch_once_t oncePredicate;
|
||||
dispatch_once(&oncePredicate, ^{
|
||||
_sharedClient = [[self alloc] initWithBaseURL:[NSURL URLWithString:kAFGowallaBaseURLString]];
|
||||
});
|
||||
|
||||
return _sharedClient;
|
||||
}
|
||||
|
||||
- (id)initWithBaseURL:(NSURL *)url {
|
||||
self = [super initWithBaseURL:url];
|
||||
if (!self) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
[self registerHTTPOperationClass:[AFJSONRequestOperation class]];
|
||||
|
||||
// X-Gowalla-API-Key HTTP Header; see http://api.gowalla.com/api/docs
|
||||
[self setDefaultHeader:@"X-Gowalla-API-Key" value:kAFGowallaClientID];
|
||||
|
||||
// X-Gowalla-API-Version HTTP Header; see http://api.gowalla.com/api/docs
|
||||
[self setDefaultHeader:@"X-Gowalla-API-Version" value:@"1"];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
30
Mac Example/Classes/Controllers/NearbySpotsController.h
Normal file
30
Mac Example/Classes/Controllers/NearbySpotsController.h
Normal file
@ -0,0 +1,30 @@
|
||||
// NearbySpotsViewController.h
|
||||
//
|
||||
// Copyright (c) 2011 Gowalla (http://gowalla.com/)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <CoreLocation/CoreLocation.h>
|
||||
|
||||
@interface NearbySpotsController : NSObject <CLLocationManagerDelegate, NSTableViewDataSource, NSTableViewDelegate>
|
||||
|
||||
@property (strong) IBOutlet NSTableView *tableView;
|
||||
|
||||
@end
|
||||
120
Mac Example/Classes/Controllers/NearbySpotsController.m
Normal file
120
Mac Example/Classes/Controllers/NearbySpotsController.m
Normal file
@ -0,0 +1,120 @@
|
||||
// NearbySpotsViewController.m
|
||||
//
|
||||
// Copyright (c) 2011 Gowalla (http://gowalla.com/)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#import "NearbySpotsController.h"
|
||||
|
||||
#import "Spot.h"
|
||||
|
||||
#import "AFImageRequestOperation.h"
|
||||
#import "AFImageCache.h"
|
||||
|
||||
@interface NearbySpotsController ()
|
||||
@property (strong) NSArray *nearbySpots;
|
||||
@property (strong) CLLocationManager *locationManager;
|
||||
@property (strong) NSOperationQueue *imageOperationQueue;
|
||||
|
||||
- (void)loadSpotsForLocation:(CLLocation *)location;
|
||||
@end
|
||||
|
||||
@implementation NearbySpotsController
|
||||
@synthesize nearbySpots = _nearbySpots;
|
||||
@synthesize locationManager = _locationManager;
|
||||
@synthesize imageOperationQueue = _imageOperationQueue;
|
||||
@synthesize tableView = _tableView;
|
||||
|
||||
- (id)init {
|
||||
self = [super init];
|
||||
if (!self) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
self.nearbySpots = [NSArray array];
|
||||
|
||||
self.locationManager = [[CLLocationManager alloc] init];
|
||||
self.locationManager.delegate = self;
|
||||
self.locationManager.distanceFilter = 80.0;
|
||||
|
||||
self.imageOperationQueue = [[NSOperationQueue alloc] init];
|
||||
self.imageOperationQueue.maxConcurrentOperationCount = 8;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)awakeFromNib {
|
||||
[self.locationManager startUpdatingLocation];
|
||||
}
|
||||
|
||||
- (void)loadSpotsForLocation:(CLLocation *)location {
|
||||
[Spot spotsWithURLString:@"/spots" near:location parameters:[NSDictionary dictionaryWithObject:@"128" forKey:@"per_page"] block:^(NSArray *records) {
|
||||
self.nearbySpots = [records sortedArrayUsingComparator:^ NSComparisonResult(id obj1, id obj2) {
|
||||
CLLocationDistance d1 = [[(Spot *)obj1 location] distanceFromLocation:location];
|
||||
CLLocationDistance d2 = [[(Spot *)obj2 location] distanceFromLocation:location];
|
||||
|
||||
if (d1 < d2) {
|
||||
return NSOrderedAscending;
|
||||
} else if (d1 > d2) {
|
||||
return NSOrderedDescending;
|
||||
} else {
|
||||
return NSOrderedSame;
|
||||
}
|
||||
}];
|
||||
|
||||
[self.tableView reloadData];
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - CLLocationManagerDelegate
|
||||
|
||||
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
|
||||
[self loadSpotsForLocation:newLocation];
|
||||
}
|
||||
|
||||
#pragma mark - NSTableViewDataSource
|
||||
|
||||
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView {
|
||||
return [self.nearbySpots count];
|
||||
}
|
||||
|
||||
- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
|
||||
Spot *spot = [self.nearbySpots objectAtIndex:row];
|
||||
|
||||
if ([[tableColumn dataCell] isMemberOfClass:[NSImageCell class]]) {
|
||||
NSURL *imageURL = [NSURL URLWithString:spot.imageURLString];
|
||||
NSImage *image = [[AFImageCache sharedImageCache] cachedImageForURL:imageURL cacheName:nil];
|
||||
if (!image) {
|
||||
NSURLRequest *imageRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:spot.imageURLString]];
|
||||
AFImageRequestOperation *operation = [AFImageRequestOperation imageRequestOperationWithRequest:imageRequest success:^(NSImage *image) {
|
||||
|
||||
[tableView reloadDataForRowIndexes:[NSIndexSet indexSetWithIndex:row] columnIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 2)]];
|
||||
}];
|
||||
[self.imageOperationQueue addOperation:operation];
|
||||
|
||||
image = [NSImage imageNamed:@"placeholder-stamp.png"];
|
||||
}
|
||||
|
||||
return image;
|
||||
} else {
|
||||
return spot.name;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
43
Mac Example/Classes/Models/Spot.h
Normal file
43
Mac Example/Classes/Models/Spot.h
Normal file
@ -0,0 +1,43 @@
|
||||
// Spot.h
|
||||
//
|
||||
// Copyright (c) 2011 Gowalla (http://gowalla.com/)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <CoreLocation/CoreLocation.h>
|
||||
|
||||
@interface Spot : NSObject {
|
||||
@private
|
||||
NSString *_name;
|
||||
NSString *_imageURLString;
|
||||
NSNumber *_latitude;
|
||||
NSNumber *_longitude;
|
||||
}
|
||||
|
||||
@property (strong) NSString *name;
|
||||
@property (strong) NSString *imageURLString;
|
||||
@property (strong) NSNumber *latitude;
|
||||
@property (strong) NSNumber *longitude;
|
||||
@property (readonly) CLLocation *location;
|
||||
|
||||
- (id)initWithAttributes:(NSDictionary *)attributes;
|
||||
+ (void)spotsWithURLString:(NSString *)urlString near:(CLLocation *)location parameters:(NSDictionary *)parameters block:(void (^)(NSArray *records))block;
|
||||
|
||||
@end
|
||||
78
Mac Example/Classes/Models/Spot.m
Normal file
78
Mac Example/Classes/Models/Spot.m
Normal file
@ -0,0 +1,78 @@
|
||||
// Spot.m
|
||||
//
|
||||
// Copyright (c) 2011 Gowalla (http://gowalla.com/)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#import "Spot.h"
|
||||
|
||||
#import "AFGowallaAPIClient.h"
|
||||
|
||||
@implementation Spot
|
||||
@synthesize name = _name;
|
||||
@synthesize imageURLString = _imageURLString;
|
||||
@synthesize latitude = _latitude;
|
||||
@synthesize longitude = _longitude;
|
||||
@dynamic location;
|
||||
|
||||
- (id)initWithAttributes:(NSDictionary *)attributes {
|
||||
self = [super init];
|
||||
if (!self) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
self.name = [attributes valueForKeyPath:@"name"];
|
||||
self.imageURLString = [attributes valueForKeyPath:@"image_url"];
|
||||
self.latitude = [attributes valueForKeyPath:@"lat"];
|
||||
self.longitude = [attributes valueForKeyPath:@"lng"];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (CLLocation *)location {
|
||||
return [[CLLocation alloc] initWithLatitude:[self.latitude doubleValue] longitude:[self.longitude doubleValue]];
|
||||
}
|
||||
|
||||
+ (void)spotsWithURLString:(NSString *)urlString near:(CLLocation *)location parameters:(NSDictionary *)parameters block:(void (^)(NSArray *records))block {
|
||||
|
||||
NSLog(@"GET");
|
||||
NSDictionary *mutableParameters = [NSMutableDictionary dictionaryWithDictionary:parameters];
|
||||
if (location) {
|
||||
[mutableParameters setValue:[NSString stringWithFormat:@"%1.7f", location.coordinate.latitude] forKey:@"lat"];
|
||||
[mutableParameters setValue:[NSString stringWithFormat:@"%1.7f", location.coordinate.longitude] forKey:@"lng"];
|
||||
}
|
||||
|
||||
[[AFGowallaAPIClient sharedClient] getPath:urlString parameters:mutableParameters success:^(id object) {
|
||||
NSMutableArray *mutableRecords = [NSMutableArray array];
|
||||
for (NSDictionary *attributes in [object valueForKeyPath:@"spots"]) {
|
||||
Spot *spot = [[Spot alloc] initWithAttributes:attributes];
|
||||
[mutableRecords addObject:spot];
|
||||
}
|
||||
|
||||
if (block) {
|
||||
block([NSArray arrayWithArray:mutableRecords]);
|
||||
}
|
||||
} failure:^(NSHTTPURLResponse *response, NSError *error) {
|
||||
if (block) {
|
||||
block([NSArray array]);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
BIN
Mac Example/Images/placeholder-stamp.png
Normal file
BIN
Mac Example/Images/placeholder-stamp.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.9 KiB |
@ -12,10 +12,16 @@
|
||||
</object>
|
||||
<object class="NSArray" key="IBDocument.IntegratedClassDependencies">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>NSWindowTemplate</string>
|
||||
<string>NSView</string>
|
||||
<string>NSMenu</string>
|
||||
<string>NSScrollView</string>
|
||||
<string>NSWindowTemplate</string>
|
||||
<string>NSMenuItem</string>
|
||||
<string>NSTableView</string>
|
||||
<string>NSTextFieldCell</string>
|
||||
<string>NSImageCell</string>
|
||||
<string>NSTableColumn</string>
|
||||
<string>NSScroller</string>
|
||||
<string>NSCustomObject</string>
|
||||
</object>
|
||||
<object class="NSArray" key="IBDocument.PluginDependencies">
|
||||
@ -1317,19 +1323,218 @@
|
||||
<object class="NSWindowTemplate" id="972006081">
|
||||
<int key="NSWindowStyleMask">15</int>
|
||||
<int key="NSWindowBacking">2</int>
|
||||
<string key="NSWindowRect">{{335, 390}, {480, 360}}</string>
|
||||
<string key="NSWindowRect">{{50, 538}, {375, 500}}</string>
|
||||
<int key="NSWTFlags">1954021376</int>
|
||||
<string key="NSWindowTitle">AFNetworking Mac Example</string>
|
||||
<string key="NSWindowClass">NSWindow</string>
|
||||
<nil key="NSViewClass"/>
|
||||
<nil key="NSUserInterfaceItemIdentifier"/>
|
||||
<string key="NSWindowContentMaxSize">{375, 1280}</string>
|
||||
<string key="NSWindowContentMinSize">{375, 200}</string>
|
||||
<object class="NSView" key="NSWindowView" id="439893737">
|
||||
<nil key="NSNextResponder"/>
|
||||
<reference key="NSNextResponder"/>
|
||||
<int key="NSvFlags">256</int>
|
||||
<string key="NSFrameSize">{480, 360}</string>
|
||||
<object class="NSMutableArray" key="NSSubviews">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSScrollView" id="905625827">
|
||||
<reference key="NSNextResponder" ref="439893737"/>
|
||||
<int key="NSvFlags">274</int>
|
||||
<object class="NSMutableArray" key="NSSubviews">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSClipView" id="411548182">
|
||||
<reference key="NSNextResponder" ref="905625827"/>
|
||||
<int key="NSvFlags">2304</int>
|
||||
<object class="NSMutableArray" key="NSSubviews">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSTableView" id="256434433">
|
||||
<reference key="NSNextResponder" ref="411548182"/>
|
||||
<int key="NSvFlags">256</int>
|
||||
<string key="NSFrameSize">{373, 498}</string>
|
||||
<reference key="NSSuperview" ref="411548182"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="830874312"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:1197</string>
|
||||
<bool key="NSEnabled">YES</bool>
|
||||
<object class="_NSCornerView" key="NSCornerView">
|
||||
<nil key="NSNextResponder"/>
|
||||
<int key="NSvFlags">-2147483392</int>
|
||||
<string key="NSFrame">{{224, 0}, {16, 17}}</string>
|
||||
<string key="NSReuseIdentifierKey">_NS:1202</string>
|
||||
</object>
|
||||
<object class="NSMutableArray" key="NSTableColumns">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSTableColumn" id="553559566">
|
||||
<double key="NSWidth">129.5078125</double>
|
||||
<double key="NSMinWidth">100</double>
|
||||
<double key="NSMaxWidth">130</double>
|
||||
<object class="NSTableHeaderCell" key="NSHeaderCell">
|
||||
<int key="NSCellFlags">75628096</int>
|
||||
<int key="NSCellFlags2">2048</int>
|
||||
<string key="NSContents"/>
|
||||
<object class="NSFont" key="NSSupport" id="26">
|
||||
<string key="NSName">LucidaGrande</string>
|
||||
<double key="NSSize">11</double>
|
||||
<int key="NSfFlags">3100</int>
|
||||
</object>
|
||||
<object class="NSColor" key="NSBackgroundColor" id="852838638">
|
||||
<int key="NSColorSpace">3</int>
|
||||
<bytes key="NSWhite">MC4zMzMzMzI5ODU2AA</bytes>
|
||||
</object>
|
||||
<object class="NSColor" key="NSTextColor" id="705481664">
|
||||
<int key="NSColorSpace">6</int>
|
||||
<string key="NSCatalogName">System</string>
|
||||
<string key="NSColorName">headerTextColor</string>
|
||||
<object class="NSColor" key="NSColor" id="840334811">
|
||||
<int key="NSColorSpace">3</int>
|
||||
<bytes key="NSWhite">MAA</bytes>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSImageCell" key="NSDataCell" id="717955434">
|
||||
<int key="NSCellFlags">67239424</int>
|
||||
<int key="NSCellFlags2">33554432</int>
|
||||
<object class="NSFont" key="NSSupport">
|
||||
<string key="NSName">LucidaGrande</string>
|
||||
<double key="NSSize">13</double>
|
||||
<int key="NSfFlags">1044</int>
|
||||
</object>
|
||||
<string key="NSCellIdentifier">_NS:4045</string>
|
||||
<int key="NSAlign">1</int>
|
||||
<int key="NSScale">0</int>
|
||||
<int key="NSStyle">0</int>
|
||||
<bool key="NSAnimates">NO</bool>
|
||||
</object>
|
||||
<int key="NSResizingMask">3</int>
|
||||
<bool key="NSIsResizeable">YES</bool>
|
||||
<bool key="NSIsEditable">YES</bool>
|
||||
<reference key="NSTableView" ref="256434433"/>
|
||||
</object>
|
||||
<object class="NSTableColumn" id="879600957">
|
||||
<double key="NSWidth">223</double>
|
||||
<double key="NSMinWidth">40</double>
|
||||
<double key="NSMaxWidth">1000</double>
|
||||
<object class="NSTableHeaderCell" key="NSHeaderCell">
|
||||
<int key="NSCellFlags">75628096</int>
|
||||
<int key="NSCellFlags2">2048</int>
|
||||
<string key="NSContents"/>
|
||||
<reference key="NSSupport" ref="26"/>
|
||||
<reference key="NSBackgroundColor" ref="852838638"/>
|
||||
<reference key="NSTextColor" ref="705481664"/>
|
||||
</object>
|
||||
<object class="NSTextFieldCell" key="NSDataCell" id="722199198">
|
||||
<int key="NSCellFlags">337772032</int>
|
||||
<int key="NSCellFlags2">0</int>
|
||||
<string key="NSContents">Text Cell</string>
|
||||
<object class="NSFont" key="NSSupport">
|
||||
<string key="NSName">LucidaGrande</string>
|
||||
<double key="NSSize">16</double>
|
||||
<int key="NSfFlags">16</int>
|
||||
</object>
|
||||
<reference key="NSControlView" ref="256434433"/>
|
||||
<object class="NSColor" key="NSBackgroundColor" id="100074496">
|
||||
<int key="NSColorSpace">6</int>
|
||||
<string key="NSCatalogName">System</string>
|
||||
<string key="NSColorName">controlBackgroundColor</string>
|
||||
<object class="NSColor" key="NSColor">
|
||||
<int key="NSColorSpace">3</int>
|
||||
<bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSColor" key="NSTextColor">
|
||||
<int key="NSColorSpace">6</int>
|
||||
<string key="NSCatalogName">System</string>
|
||||
<string key="NSColorName">controlTextColor</string>
|
||||
<reference key="NSColor" ref="840334811"/>
|
||||
</object>
|
||||
</object>
|
||||
<int key="NSResizingMask">3</int>
|
||||
<bool key="NSIsResizeable">YES</bool>
|
||||
<bool key="NSIsEditable">YES</bool>
|
||||
<reference key="NSTableView" ref="256434433"/>
|
||||
</object>
|
||||
</object>
|
||||
<double key="NSIntercellSpacingWidth">10</double>
|
||||
<double key="NSIntercellSpacingHeight">10</double>
|
||||
<object class="NSColor" key="NSBackgroundColor">
|
||||
<int key="NSColorSpace">3</int>
|
||||
<bytes key="NSWhite">MQA</bytes>
|
||||
</object>
|
||||
<object class="NSColor" key="NSGridColor">
|
||||
<int key="NSColorSpace">6</int>
|
||||
<string key="NSCatalogName">System</string>
|
||||
<string key="NSColorName">gridColor</string>
|
||||
<object class="NSColor" key="NSColor">
|
||||
<int key="NSColorSpace">3</int>
|
||||
<bytes key="NSWhite">MC41AA</bytes>
|
||||
</object>
|
||||
</object>
|
||||
<double key="NSRowHeight">60</double>
|
||||
<int key="NSTvFlags">373293056</int>
|
||||
<reference key="NSDelegate"/>
|
||||
<reference key="NSDataSource"/>
|
||||
<int key="NSColumnAutoresizingStyle">4</int>
|
||||
<int key="NSDraggingSourceMaskForLocal">15</int>
|
||||
<int key="NSDraggingSourceMaskForNonLocal">0</int>
|
||||
<bool key="NSAllowsTypeSelect">YES</bool>
|
||||
<int key="NSTableViewDraggingDestinationStyle">0</int>
|
||||
<int key="NSTableViewGroupRowStyle">1</int>
|
||||
</object>
|
||||
</object>
|
||||
<string key="NSFrame">{{1, 1}, {373, 498}}</string>
|
||||
<reference key="NSSuperview" ref="905625827"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="256434433"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:1195</string>
|
||||
<reference key="NSDocView" ref="256434433"/>
|
||||
<reference key="NSBGColor" ref="100074496"/>
|
||||
<int key="NScvFlags">4</int>
|
||||
</object>
|
||||
<object class="NSScroller" id="830874312">
|
||||
<reference key="NSNextResponder" ref="905625827"/>
|
||||
<int key="NSvFlags">-2147483392</int>
|
||||
<string key="NSFrame">{{224, 17}, {15, 102}}</string>
|
||||
<reference key="NSSuperview" ref="905625827"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="870849666"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:1214</string>
|
||||
<reference key="NSTarget" ref="905625827"/>
|
||||
<string key="NSAction">_doScroller:</string>
|
||||
<double key="NSPercent">0.99815157116451014</double>
|
||||
</object>
|
||||
<object class="NSScroller" id="870849666">
|
||||
<reference key="NSNextResponder" ref="905625827"/>
|
||||
<int key="NSvFlags">-2147483392</int>
|
||||
<string key="NSFrame">{{1, 526}, {374, 15}}</string>
|
||||
<reference key="NSSuperview" ref="905625827"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:1216</string>
|
||||
<int key="NSsFlags">1</int>
|
||||
<reference key="NSTarget" ref="905625827"/>
|
||||
<string key="NSAction">_doScroller:</string>
|
||||
<double key="NSPercent">0.99733333333333329</double>
|
||||
</object>
|
||||
</object>
|
||||
<string key="NSFrameSize">{375, 500}</string>
|
||||
<reference key="NSSuperview" ref="439893737"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="411548182"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:1193</string>
|
||||
<int key="NSsFlags">133682</int>
|
||||
<reference key="NSVScroller" ref="830874312"/>
|
||||
<reference key="NSHScroller" ref="870849666"/>
|
||||
<reference key="NSContentView" ref="411548182"/>
|
||||
<bytes key="NSScrollAmts">QSAAAEEgAABCjAAAQowAAA</bytes>
|
||||
</object>
|
||||
</object>
|
||||
<string key="NSFrameSize">{375, 500}</string>
|
||||
<reference key="NSSuperview"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="905625827"/>
|
||||
</object>
|
||||
<string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
|
||||
<string key="NSMaxSize">{10000000000000, 10000000000000}</string>
|
||||
<string key="NSMinSize">{375, 222}</string>
|
||||
<string key="NSMaxSize">{375, 1302}</string>
|
||||
<bool key="NSWindowIsRestorable">YES</bool>
|
||||
</object>
|
||||
<object class="NSCustomObject" id="976324537">
|
||||
@ -1338,6 +1543,9 @@
|
||||
<object class="NSCustomObject" id="755631768">
|
||||
<string key="NSClassName">NSFontManager</string>
|
||||
</object>
|
||||
<object class="NSCustomObject" id="815842389">
|
||||
<string key="NSClassName">NearbySpotsController</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBObjectContainer" key="IBDocument.Objects">
|
||||
<object class="NSMutableArray" key="connectionRecords">
|
||||
@ -2022,6 +2230,30 @@
|
||||
</object>
|
||||
<int key="connectionID">535</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBOutletConnection" key="connection">
|
||||
<string key="label">tableView</string>
|
||||
<reference key="source" ref="815842389"/>
|
||||
<reference key="destination" ref="256434433"/>
|
||||
</object>
|
||||
<int key="connectionID">550</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBOutletConnection" key="connection">
|
||||
<string key="label">dataSource</string>
|
||||
<reference key="source" ref="256434433"/>
|
||||
<reference key="destination" ref="815842389"/>
|
||||
</object>
|
||||
<int key="connectionID">551</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBOutletConnection" key="connection">
|
||||
<string key="label">delegate</string>
|
||||
<reference key="source" ref="256434433"/>
|
||||
<reference key="destination" ref="815842389"/>
|
||||
</object>
|
||||
<int key="connectionID">552</int>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBMutableOrderedSet" key="objectRecords">
|
||||
<object class="NSArray" key="orderedObjects">
|
||||
@ -2572,6 +2804,10 @@
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">372</int>
|
||||
<reference key="object" ref="439893737"/>
|
||||
<object class="NSMutableArray" key="children">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference ref="905625827"/>
|
||||
</object>
|
||||
<reference key="parent" ref="972006081"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
@ -3065,6 +3301,70 @@
|
||||
<reference key="object" ref="738670835"/>
|
||||
<reference key="parent" ref="963351320"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">537</int>
|
||||
<reference key="object" ref="905625827"/>
|
||||
<object class="NSMutableArray" key="children">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference ref="830874312"/>
|
||||
<reference ref="870849666"/>
|
||||
<reference ref="256434433"/>
|
||||
</object>
|
||||
<reference key="parent" ref="439893737"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">538</int>
|
||||
<reference key="object" ref="830874312"/>
|
||||
<reference key="parent" ref="905625827"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">540</int>
|
||||
<reference key="object" ref="870849666"/>
|
||||
<reference key="parent" ref="905625827"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">541</int>
|
||||
<reference key="object" ref="256434433"/>
|
||||
<object class="NSMutableArray" key="children">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference ref="553559566"/>
|
||||
<reference ref="879600957"/>
|
||||
</object>
|
||||
<reference key="parent" ref="905625827"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">542</int>
|
||||
<reference key="object" ref="553559566"/>
|
||||
<object class="NSMutableArray" key="children">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference ref="717955434"/>
|
||||
</object>
|
||||
<reference key="parent" ref="256434433"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">543</int>
|
||||
<reference key="object" ref="879600957"/>
|
||||
<object class="NSMutableArray" key="children">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference ref="722199198"/>
|
||||
</object>
|
||||
<reference key="parent" ref="256434433"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">544</int>
|
||||
<reference key="object" ref="722199198"/>
|
||||
<reference key="parent" ref="879600957"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">546</int>
|
||||
<reference key="object" ref="717955434"/>
|
||||
<reference key="parent" ref="553559566"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">549</int>
|
||||
<reference key="object" ref="815842389"/>
|
||||
<reference key="parent" ref="0"/>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="flattenedProperties">
|
||||
@ -3211,6 +3511,15 @@
|
||||
<string>516.IBPluginDependency</string>
|
||||
<string>517.IBPluginDependency</string>
|
||||
<string>534.IBPluginDependency</string>
|
||||
<string>537.IBPluginDependency</string>
|
||||
<string>538.IBPluginDependency</string>
|
||||
<string>540.IBPluginDependency</string>
|
||||
<string>541.IBPluginDependency</string>
|
||||
<string>542.IBPluginDependency</string>
|
||||
<string>543.IBPluginDependency</string>
|
||||
<string>544.IBPluginDependency</string>
|
||||
<string>546.IBPluginDependency</string>
|
||||
<string>549.IBPluginDependency</string>
|
||||
<string>56.IBPluginDependency</string>
|
||||
<string>57.IBPluginDependency</string>
|
||||
<string>58.IBPluginDependency</string>
|
||||
@ -3382,6 +3691,15 @@
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="unlocalizedProperties">
|
||||
@ -3396,7 +3714,7 @@
|
||||
<reference key="dict.values" ref="0"/>
|
||||
</object>
|
||||
<nil key="sourceID"/>
|
||||
<int key="maxID">535</int>
|
||||
<int key="maxID">554</int>
|
||||
</object>
|
||||
<object class="IBClassDescriber" key="IBDocument.Classes">
|
||||
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
|
||||
@ -3487,6 +3805,25 @@
|
||||
<string key="minorKey">./Classes/NSDocument.h</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBPartialClassDescription">
|
||||
<string key="className">NearbySpotsController</string>
|
||||
<string key="superclassName">NSObject</string>
|
||||
<object class="NSMutableDictionary" key="outlets">
|
||||
<string key="NS.key.0">tableView</string>
|
||||
<string key="NS.object.0">NSTableView</string>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
|
||||
<string key="NS.key.0">tableView</string>
|
||||
<object class="IBToOneOutletInfo" key="NS.object.0">
|
||||
<string key="name">tableView</string>
|
||||
<string key="candidateClassName">NSTableView</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBClassDescriptionSource" key="sourceIdentifier">
|
||||
<string key="majorKey">IBProjectSource</string>
|
||||
<string key="minorKey">./Classes/NearbySpotsController.h</string>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<int key="IBDocument.localizationMode">0</int>
|
||||
|
||||
@ -0,0 +1,75 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "F8E4695F1395739C00DB05C8"
|
||||
BuildableName = "AFNetworkingExample.app"
|
||||
BlueprintName = "AFNetworkingExample"
|
||||
ReferencedContainer = "container:AFNetworking iOS Example.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
buildConfiguration = "Debug">
|
||||
<Testables>
|
||||
</Testables>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Debug"
|
||||
debugDocumentVersioning = "YES"
|
||||
allowLocationSimulation = "YES">
|
||||
<BuildableProductRunnable>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "F8E4695F1395739C00DB05C8"
|
||||
BuildableName = "AFNetworkingExample.app"
|
||||
BlueprintName = "AFNetworkingExample"
|
||||
ReferencedContainer = "container:AFNetworking iOS Example.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Release"
|
||||
debugDocumentVersioning = "YES">
|
||||
<BuildableProductRunnable>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "F8E4695F1395739C00DB05C8"
|
||||
BuildableName = "AFNetworkingExample.app"
|
||||
BlueprintName = "AFNetworkingExample"
|
||||
ReferencedContainer = "container:AFNetworking iOS Example.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>SchemeUserState</key>
|
||||
<dict>
|
||||
<key>AFNetworkingExample.xcscheme</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>1</integer>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>SuppressBuildableAutocreation</key>
|
||||
<dict>
|
||||
<key>F8E4695F1395739C00DB05C8</key>
|
||||
<dict>
|
||||
<key>primary</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
@ -47,6 +47,8 @@ NSString * const kAFGowallaBaseURLString = @"https://api.gowalla.com/";
|
||||
return nil;
|
||||
}
|
||||
|
||||
[self registerHTTPOperationClass:[AFJSONRequestOperation class]];
|
||||
|
||||
// X-Gowalla-API-Key HTTP Header; see http://api.gowalla.com/api/docs
|
||||
[self setDefaultHeader:@"X-Gowalla-API-Key" value:kAFGowallaClientID];
|
||||
|
||||
@ -55,9 +57,7 @@ NSString * const kAFGowallaBaseURLString = @"https://api.gowalla.com/";
|
||||
|
||||
// X-UDID HTTP Header
|
||||
[self setDefaultHeader:@"X-UDID" value:[[UIDevice currentDevice] uniqueIdentifier]];
|
||||
|
||||
[self registerHTTPOperationClass:[AFJSONRequestOperation class]];
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
@ -23,8 +23,6 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <CoreLocation/CoreLocation.h>
|
||||
|
||||
typedef void (^AFRecordsBlock)(NSArray *records);
|
||||
|
||||
@interface Spot : NSObject {
|
||||
@private
|
||||
NSString *_name;
|
||||
@ -40,6 +38,6 @@ typedef void (^AFRecordsBlock)(NSArray *records);
|
||||
@property (readonly) CLLocation *location;
|
||||
|
||||
- (id)initWithAttributes:(NSDictionary *)attributes;
|
||||
+ (void)spotsWithURLString:(NSString *)urlString near:(CLLocation *)location parameters:(NSDictionary *)parameters block:(AFRecordsBlock)block;
|
||||
+ (void)spotsWithURLString:(NSString *)urlString near:(CLLocation *)location parameters:(NSDictionary *)parameters block:(void (^)(NSArray *records))block;
|
||||
|
||||
@end
|
||||
|
||||
@ -57,7 +57,7 @@
|
||||
return [[[CLLocation alloc] initWithLatitude:[self.latitude doubleValue] longitude:[self.longitude doubleValue]] autorelease];
|
||||
}
|
||||
|
||||
+ (void)spotsWithURLString:(NSString *)urlString near:(CLLocation *)location parameters:(NSDictionary *)parameters block:(AFRecordsBlock)block {
|
||||
+ (void)spotsWithURLString:(NSString *)urlString near:(CLLocation *)location parameters:(NSDictionary *)parameters block:(void (^)(NSArray *records))block {
|
||||
NSDictionary *mutableParameters = [NSMutableDictionary dictionaryWithDictionary:parameters];
|
||||
if (location) {
|
||||
[mutableParameters setValue:[NSString stringWithFormat:@"%1.7f", location.coordinate.latitude] forKey:@"lat"];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user