Adding Mac example project
Renaming iOS example project Adding AFNetworking to Mac project using preprocessor macros to resolve UIKit dependencies, and setting compiler flags accordingly.
This commit is contained in:
parent
b621ad0848
commit
efdaedc541
47 changed files with 9890 additions and 3 deletions
|
|
@ -119,8 +119,8 @@ static NSString * AFURLEncodedStringFromStringWithEncoding(NSString *string, NSS
|
|||
NSString *preferredLanguageCodes = [[NSLocale preferredLanguages] componentsJoinedByString:@", "];
|
||||
[self setDefaultHeader:@"Accept-Language" value:[NSString stringWithFormat:@"%@, en-us;q=0.8", preferredLanguageCodes]];
|
||||
|
||||
// User-Agent Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43
|
||||
[self setDefaultHeader:@"User-Agent" value:[NSString stringWithFormat:@"%@/%@ (%@, %@ %@, %@, Scale/%f)", [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleIdentifierKey], [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleVersionKey], @"unknown", [[UIDevice currentDevice] systemName], [[UIDevice currentDevice] systemVersion], [[UIDevice currentDevice] model], ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] ? [[UIScreen mainScreen] scale] : 1.0)]];
|
||||
// // User-Agent Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43
|
||||
// [self setDefaultHeader:@"User-Agent" value:[NSString stringWithFormat:@"%@/%@ (%@, %@ %@, %@, Scale/%f)", [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleIdentifierKey], [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleVersionKey], @"unknown", [[UIDevice currentDevice] systemName], [[UIDevice currentDevice] systemVersion], [[UIDevice currentDevice] model], ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] ? [[UIScreen mainScreen] scale] : 1.0)]];
|
||||
|
||||
self.operationQueue = [[[NSOperationQueue alloc] init] autorelease];
|
||||
[self.operationQueue setMaxConcurrentOperationCount:2];
|
||||
|
|
|
|||
|
|
@ -225,6 +225,7 @@ static NSThread *_networkRequestThread = nil;
|
|||
[self didChangeValueForKey:oldStateKey];
|
||||
[self didChangeValueForKey:newStateKey];
|
||||
|
||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED
|
||||
switch (state) {
|
||||
case AFHTTPOperationExecutingState:
|
||||
[[AFNetworkActivityIndicatorManager sharedManager] incrementActivityCount];
|
||||
|
|
@ -237,6 +238,7 @@ static NSThread *_networkRequestThread = nil;
|
|||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)setCancelled:(BOOL)cancelled {
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@
|
|||
#import <Foundation/Foundation.h>
|
||||
#import "AFImageRequestOperation.h"
|
||||
|
||||
#import <Availability.h>
|
||||
|
||||
/**
|
||||
`AFImageCache` is a subclass of `NSCache` that stores and retrieves images from cache.
|
||||
|
||||
|
|
@ -45,8 +47,11 @@
|
|||
|
||||
@return The image associated with the URL and cache name, or `nil` if not image exists.
|
||||
*/
|
||||
|
||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED
|
||||
- (UIImage *)cachedImageForURL:(NSURL *)url
|
||||
cacheName:(NSString *)cacheName;
|
||||
#endif
|
||||
|
||||
/**
|
||||
Stores an image into cache, associated with a given URL and cache name.
|
||||
|
|
@ -55,8 +60,11 @@
|
|||
@param url The URL to be associated with the image.
|
||||
@param cacheName The cache name to be associated with the image in the cache. This allows for multiple versions of an image to be associated for a single URL, such as image thumbnails, for instance.
|
||||
*/
|
||||
|
||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED
|
||||
- (void)cacheImage:(UIImage *)image
|
||||
forURL:(NSURL *)url
|
||||
cacheName:(NSString *)cacheName;
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -39,12 +39,15 @@ static inline NSString * AFImageCacheKeyFromURLAndCacheName(NSURL *url, NSString
|
|||
return _sharedImageCache;
|
||||
}
|
||||
|
||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED
|
||||
- (UIImage *)cachedImageForURL:(NSURL *)url
|
||||
cacheName:(NSString *)cacheName
|
||||
{
|
||||
return [self objectForKey:AFImageCacheKeyFromURLAndCacheName(url, cacheName)];
|
||||
}
|
||||
#endif
|
||||
|
||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED
|
||||
- (void)cacheImage:(UIImage *)image
|
||||
forURL:(NSURL *)url
|
||||
cacheName:(NSString *)cacheName
|
||||
|
|
@ -55,5 +58,6 @@ static inline NSString * AFImageCacheKeyFromURLAndCacheName(NSURL *url, NSString
|
|||
|
||||
[self setObject:image forKey:AFImageCacheKeyFromURLAndCacheName(url, cacheName)];
|
||||
}
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -21,9 +21,10 @@
|
|||
// THE SOFTWARE.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "AFHTTPRequestOperation.h"
|
||||
|
||||
#import <Availability.h>
|
||||
|
||||
/**
|
||||
`AFImageRequestOperation` is an `NSOperation` that wraps the callback from `AFHTTPRequestOperation` to create an image from the response body, and optionally cache the image to memory.
|
||||
|
||||
|
|
@ -40,8 +41,11 @@
|
|||
|
||||
@return A new image request operation
|
||||
*/
|
||||
|
||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED
|
||||
+ (AFImageRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
|
||||
success:(void (^)(UIImage *image))success;
|
||||
#endif
|
||||
|
||||
/**
|
||||
Creates and returns an `AFImageRequestOperation` object and sets the specified success callback.
|
||||
|
|
@ -54,10 +58,13 @@
|
|||
|
||||
@return A new image request operation
|
||||
*/
|
||||
|
||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED
|
||||
+ (AFImageRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
|
||||
imageProcessingBlock:(UIImage *(^)(UIImage *))imageProcessingBlock
|
||||
cacheName:(NSString *)cacheNameOrNil
|
||||
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success
|
||||
failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure;
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@ static dispatch_queue_t image_request_operation_processing_queue() {
|
|||
|
||||
@implementation AFImageRequestOperation
|
||||
|
||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED
|
||||
|
||||
+ (AFImageRequestOperation *)operationWithRequest:(NSURLRequest *)urlRequest
|
||||
success:(void (^)(UIImage *image))success
|
||||
{
|
||||
|
|
@ -85,4 +87,6 @@ static dispatch_queue_t image_request_operation_processing_queue() {
|
|||
}];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@
|
|||
/**
|
||||
`AFNetworkActivityIndicatorManager` manages the state of the network activity indicator in the status bar. When network operations start, they can call `-incrementActivityCount`, and once they're finished, call `-decrementActivityCount`. The number of active requests is incremented and decremented much like a stack or a semaphore, and the activity indicator will animate so long as that number is greater than zero.
|
||||
*/
|
||||
|
||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED
|
||||
@interface AFNetworkActivityIndicatorManager : NSObject {
|
||||
@private
|
||||
NSInteger _activityCount;
|
||||
|
|
@ -48,3 +50,4 @@
|
|||
- (void)decrementActivityCount;
|
||||
|
||||
@end
|
||||
#endif
|
||||
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#import "AFNetworkActivityIndicatorManager.h"
|
||||
|
||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED
|
||||
@interface AFNetworkActivityIndicatorManager ()
|
||||
@property (readwrite, nonatomic, assign) NSInteger activityCount;
|
||||
@end
|
||||
|
|
@ -60,3 +61,4 @@
|
|||
}
|
||||
|
||||
@end
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -20,6 +20,9 @@
|
|||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#import <Availability.h>
|
||||
|
||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "AFImageRequestOperation.h"
|
||||
|
||||
|
|
@ -71,3 +74,4 @@
|
|||
- (void)cancelImageRequestOperation;
|
||||
|
||||
@end
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@
|
|||
#import <Foundation/Foundation.h>
|
||||
#import <objc/runtime.h>
|
||||
|
||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED
|
||||
|
||||
#import "UIImageView+AFNetworking.h"
|
||||
|
||||
#import "AFImageCache.h"
|
||||
|
|
@ -170,3 +172,4 @@ static NSString * const kUIImageViewImageRequestObjectKey = @"_af_imageRequestOp
|
|||
}
|
||||
|
||||
@end
|
||||
#endif
|
||||
|
|
|
|||
359
Mac Example/AFNetworking Mac Example.xcodeproj/project.pbxproj
Normal file
359
Mac Example/AFNetworking Mac Example.xcodeproj/project.pbxproj
Normal file
|
|
@ -0,0 +1,359 @@
|
|||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 46;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
F8A27A2C142CF24700F5E0D6 /* AFHTTPClient.m in Sources */ = {isa = PBXBuildFile; fileRef = F8A27A1F142CF24700F5E0D6 /* AFHTTPClient.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||
F8A27A2D142CF24700F5E0D6 /* AFHTTPRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F8A27A21142CF24700F5E0D6 /* AFHTTPRequestOperation.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||
F8A27A2E142CF24700F5E0D6 /* AFImageCache.m in Sources */ = {isa = PBXBuildFile; fileRef = F8A27A23142CF24700F5E0D6 /* AFImageCache.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||
F8A27A2F142CF24700F5E0D6 /* AFImageRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F8A27A25142CF24700F5E0D6 /* AFImageRequestOperation.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||
F8A27A30142CF24700F5E0D6 /* AFJSONRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F8A27A27142CF24700F5E0D6 /* AFJSONRequestOperation.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||
F8A27A31142CF24700F5E0D6 /* AFNetworkActivityIndicatorManager.m in Sources */ = {isa = PBXBuildFile; fileRef = F8A27A29142CF24700F5E0D6 /* AFNetworkActivityIndicatorManager.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||
F8A27A32142CF24700F5E0D6 /* UIImageView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = F8A27A2B142CF24700F5E0D6 /* UIImageView+AFNetworking.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||
F8A27A3A142CF36100F5E0D6 /* JSONKit.m in Sources */ = {isa = PBXBuildFile; fileRef = F8A27A39142CF36100F5E0D6 /* JSONKit.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||
F8CEEB6F142CEC6E00247B03 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8CEEB6E142CEC6E00247B03 /* Cocoa.framework */; };
|
||||
F8CEEB7B142CEC6E00247B03 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = F8CEEB7A142CEC6E00247B03 /* main.m */; };
|
||||
F8CEEB7F142CEC6E00247B03 /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = F8CEEB7D142CEC6E00247B03 /* Credits.rtf */; };
|
||||
F8CEEB82142CEC6E00247B03 /* AFNetworking_Mac_ExampleAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = F8CEEB81142CEC6E00247B03 /* AFNetworking_Mac_ExampleAppDelegate.m */; };
|
||||
F8CEEB85142CEC6E00247B03 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = F8CEEB83142CEC6E00247B03 /* MainMenu.xib */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
F8A27A1E142CF24700F5E0D6 /* AFHTTPClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AFHTTPClient.h; path = AFNetworking/AFHTTPClient.h; sourceTree = "<group>"; };
|
||||
F8A27A1F142CF24700F5E0D6 /* AFHTTPClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AFHTTPClient.m; path = AFNetworking/AFHTTPClient.m; sourceTree = "<group>"; };
|
||||
F8A27A20142CF24700F5E0D6 /* AFHTTPRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AFHTTPRequestOperation.h; path = AFNetworking/AFHTTPRequestOperation.h; sourceTree = "<group>"; };
|
||||
F8A27A21142CF24700F5E0D6 /* AFHTTPRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AFHTTPRequestOperation.m; path = AFNetworking/AFHTTPRequestOperation.m; sourceTree = "<group>"; };
|
||||
F8A27A22142CF24700F5E0D6 /* AFImageCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AFImageCache.h; path = AFNetworking/AFImageCache.h; sourceTree = "<group>"; };
|
||||
F8A27A23142CF24700F5E0D6 /* AFImageCache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AFImageCache.m; path = AFNetworking/AFImageCache.m; sourceTree = "<group>"; };
|
||||
F8A27A24142CF24700F5E0D6 /* AFImageRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AFImageRequestOperation.h; path = AFNetworking/AFImageRequestOperation.h; sourceTree = "<group>"; };
|
||||
F8A27A25142CF24700F5E0D6 /* AFImageRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AFImageRequestOperation.m; path = AFNetworking/AFImageRequestOperation.m; sourceTree = "<group>"; };
|
||||
F8A27A26142CF24700F5E0D6 /* AFJSONRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AFJSONRequestOperation.h; path = AFNetworking/AFJSONRequestOperation.h; sourceTree = "<group>"; };
|
||||
F8A27A27142CF24700F5E0D6 /* AFJSONRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AFJSONRequestOperation.m; path = AFNetworking/AFJSONRequestOperation.m; sourceTree = "<group>"; };
|
||||
F8A27A28142CF24700F5E0D6 /* AFNetworkActivityIndicatorManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AFNetworkActivityIndicatorManager.h; path = AFNetworking/AFNetworkActivityIndicatorManager.h; sourceTree = "<group>"; };
|
||||
F8A27A29142CF24700F5E0D6 /* AFNetworkActivityIndicatorManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AFNetworkActivityIndicatorManager.m; path = AFNetworking/AFNetworkActivityIndicatorManager.m; sourceTree = "<group>"; };
|
||||
F8A27A2A142CF24700F5E0D6 /* UIImageView+AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIImageView+AFNetworking.h"; path = "AFNetworking/UIImageView+AFNetworking.h"; sourceTree = "<group>"; };
|
||||
F8A27A2B142CF24700F5E0D6 /* UIImageView+AFNetworking.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIImageView+AFNetworking.m"; path = "AFNetworking/UIImageView+AFNetworking.m"; sourceTree = "<group>"; };
|
||||
F8A27A38142CF36100F5E0D6 /* JSONKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSONKit.h; sourceTree = "<group>"; };
|
||||
F8A27A39142CF36100F5E0D6 /* JSONKit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JSONKit.m; sourceTree = "<group>"; };
|
||||
F8CEEB6A142CEC6E00247B03 /* AFNetworking Mac Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "AFNetworking Mac Example.app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
F8CEEB6E142CEC6E00247B03 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
|
||||
F8CEEB71142CEC6E00247B03 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; };
|
||||
F8CEEB72142CEC6E00247B03 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; };
|
||||
F8CEEB73142CEC6E00247B03 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
|
||||
F8CEEB76142CEC6E00247B03 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
F8CEEB7A142CEC6E00247B03 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
||||
F8CEEB7C142CEC6E00247B03 /* Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Prefix.pch; sourceTree = "<group>"; };
|
||||
F8CEEB7E142CEC6E00247B03 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; name = en; path = en.lproj/Credits.rtf; sourceTree = "<group>"; };
|
||||
F8CEEB80142CEC6E00247B03 /* AFNetworking_Mac_ExampleAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AFNetworking_Mac_ExampleAppDelegate.h; sourceTree = "<group>"; };
|
||||
F8CEEB81142CEC6E00247B03 /* AFNetworking_Mac_ExampleAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AFNetworking_Mac_ExampleAppDelegate.m; sourceTree = "<group>"; };
|
||||
F8CEEB84142CEC6E00247B03 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainMenu.xib; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
F8CEEB67142CEC6E00247B03 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
F8CEEB6F142CEC6E00247B03 /* Cocoa.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
F8A27A37142CF36000F5E0D6 /* JSONKit */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F8A27A38142CF36100F5E0D6 /* JSONKit.h */,
|
||||
F8A27A39142CF36100F5E0D6 /* JSONKit.m */,
|
||||
);
|
||||
name = JSONKit;
|
||||
path = "AFNetworking Mac Example/Vendor/JSONKit";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F8CEEB5F142CEC6E00247B03 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F8CEEB74142CEC6E00247B03 /* AFNetworking Mac Example */,
|
||||
F8CEEB8B142CECAA00247B03 /* Vendor */,
|
||||
F8CEEB6D142CEC6E00247B03 /* Frameworks */,
|
||||
F8CEEB6B142CEC6E00247B03 /* Products */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F8CEEB6B142CEC6E00247B03 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F8CEEB6A142CEC6E00247B03 /* AFNetworking Mac Example.app */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F8CEEB6D142CEC6E00247B03 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F8CEEB6E142CEC6E00247B03 /* Cocoa.framework */,
|
||||
F8CEEB70142CEC6E00247B03 /* Other Frameworks */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F8CEEB70142CEC6E00247B03 /* Other Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F8CEEB71142CEC6E00247B03 /* AppKit.framework */,
|
||||
F8CEEB72142CEC6E00247B03 /* CoreData.framework */,
|
||||
F8CEEB73142CEC6E00247B03 /* Foundation.framework */,
|
||||
);
|
||||
name = "Other Frameworks";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F8CEEB74142CEC6E00247B03 /* AFNetworking Mac Example */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F8CEEB80142CEC6E00247B03 /* AFNetworking_Mac_ExampleAppDelegate.h */,
|
||||
F8CEEB81142CEC6E00247B03 /* AFNetworking_Mac_ExampleAppDelegate.m */,
|
||||
F8CEEB83142CEC6E00247B03 /* MainMenu.xib */,
|
||||
F8CEEB75142CEC6E00247B03 /* Supporting Files */,
|
||||
);
|
||||
path = "AFNetworking Mac Example";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F8CEEB75142CEC6E00247B03 /* Supporting Files */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F8CEEB76142CEC6E00247B03 /* Info.plist */,
|
||||
F8CEEB7A142CEC6E00247B03 /* main.m */,
|
||||
F8CEEB7C142CEC6E00247B03 /* Prefix.pch */,
|
||||
F8CEEB7D142CEC6E00247B03 /* Credits.rtf */,
|
||||
);
|
||||
name = "Supporting Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F8CEEB8B142CECAA00247B03 /* Vendor */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F8A27A37142CF36000F5E0D6 /* JSONKit */,
|
||||
F8CEEB8C142CED6F00247B03 /* AFNetworking */,
|
||||
);
|
||||
name = Vendor;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F8CEEB8C142CED6F00247B03 /* AFNetworking */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F8A27A20142CF24700F5E0D6 /* AFHTTPRequestOperation.h */,
|
||||
F8A27A21142CF24700F5E0D6 /* AFHTTPRequestOperation.m */,
|
||||
F8A27A26142CF24700F5E0D6 /* AFJSONRequestOperation.h */,
|
||||
F8A27A27142CF24700F5E0D6 /* AFJSONRequestOperation.m */,
|
||||
F8A27A1E142CF24700F5E0D6 /* AFHTTPClient.h */,
|
||||
F8A27A1F142CF24700F5E0D6 /* AFHTTPClient.m */,
|
||||
F8A27A22142CF24700F5E0D6 /* AFImageCache.h */,
|
||||
F8A27A23142CF24700F5E0D6 /* AFImageCache.m */,
|
||||
F8A27A24142CF24700F5E0D6 /* AFImageRequestOperation.h */,
|
||||
F8A27A25142CF24700F5E0D6 /* AFImageRequestOperation.m */,
|
||||
F8A27A28142CF24700F5E0D6 /* AFNetworkActivityIndicatorManager.h */,
|
||||
F8A27A29142CF24700F5E0D6 /* AFNetworkActivityIndicatorManager.m */,
|
||||
F8A27A2A142CF24700F5E0D6 /* UIImageView+AFNetworking.h */,
|
||||
F8A27A2B142CF24700F5E0D6 /* UIImageView+AFNetworking.m */,
|
||||
);
|
||||
name = AFNetworking;
|
||||
path = ../../AFNetworking;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
F8CEEB69142CEC6E00247B03 /* AFNetworking Mac Example */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = F8CEEB88142CEC6E00247B03 /* Build configuration list for PBXNativeTarget "AFNetworking Mac Example" */;
|
||||
buildPhases = (
|
||||
F8CEEB66142CEC6E00247B03 /* Sources */,
|
||||
F8CEEB67142CEC6E00247B03 /* Frameworks */,
|
||||
F8CEEB68142CEC6E00247B03 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = "AFNetworking Mac Example";
|
||||
productName = "AFNetworking Mac Example";
|
||||
productReference = F8CEEB6A142CEC6E00247B03 /* AFNetworking Mac Example.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
F8CEEB61142CEC6E00247B03 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 0420;
|
||||
ORGANIZATIONNAME = Gowalla;
|
||||
};
|
||||
buildConfigurationList = F8CEEB64142CEC6E00247B03 /* Build configuration list for PBXProject "AFNetworking Mac Example" */;
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
);
|
||||
mainGroup = F8CEEB5F142CEC6E00247B03;
|
||||
productRefGroup = F8CEEB6B142CEC6E00247B03 /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
F8CEEB69142CEC6E00247B03 /* AFNetworking Mac Example */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
F8CEEB68142CEC6E00247B03 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
F8CEEB7F142CEC6E00247B03 /* Credits.rtf in Resources */,
|
||||
F8CEEB85142CEC6E00247B03 /* MainMenu.xib in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
F8CEEB66142CEC6E00247B03 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
F8CEEB7B142CEC6E00247B03 /* main.m in Sources */,
|
||||
F8CEEB82142CEC6E00247B03 /* AFNetworking_Mac_ExampleAppDelegate.m in Sources */,
|
||||
F8A27A2C142CF24700F5E0D6 /* AFHTTPClient.m in Sources */,
|
||||
F8A27A2D142CF24700F5E0D6 /* AFHTTPRequestOperation.m in Sources */,
|
||||
F8A27A2E142CF24700F5E0D6 /* AFImageCache.m in Sources */,
|
||||
F8A27A2F142CF24700F5E0D6 /* AFImageRequestOperation.m in Sources */,
|
||||
F8A27A30142CF24700F5E0D6 /* AFJSONRequestOperation.m in Sources */,
|
||||
F8A27A31142CF24700F5E0D6 /* AFNetworkActivityIndicatorManager.m in Sources */,
|
||||
F8A27A32142CF24700F5E0D6 /* UIImageView+AFNetworking.m in Sources */,
|
||||
F8A27A3A142CF36100F5E0D6 /* JSONKit.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXVariantGroup section */
|
||||
F8CEEB7D142CEC6E00247B03 /* Credits.rtf */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
F8CEEB7E142CEC6E00247B03 /* en */,
|
||||
);
|
||||
name = Credits.rtf;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F8CEEB83142CEC6E00247B03 /* MainMenu.xib */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
F8CEEB84142CEC6E00247B03 /* en */,
|
||||
);
|
||||
name = MainMenu.xib;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXVariantGroup section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
F8CEEB86142CEC6E00247B03 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.6;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = macosx;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
F8CEEB87142CEC6E00247B03 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
COPY_PHASE_STRIP = YES;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
|
||||
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.6;
|
||||
SDKROOT = macosx;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
F8CEEB89142CEC6E00247B03 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = "AFNetworking Mac Example/Prefix.pch";
|
||||
INFOPLIST_FILE = "AFNetworking Mac Example/Info.plist";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
WRAPPER_EXTENSION = app;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
F8CEEB8A142CEC6E00247B03 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = "AFNetworking Mac Example/Prefix.pch";
|
||||
INFOPLIST_FILE = "AFNetworking Mac Example/Info.plist";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
WRAPPER_EXTENSION = app;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
F8CEEB64142CEC6E00247B03 /* Build configuration list for PBXProject "AFNetworking Mac Example" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
F8CEEB86142CEC6E00247B03 /* Debug */,
|
||||
F8CEEB87142CEC6E00247B03 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
F8CEEB88142CEC6E00247B03 /* Build configuration list for PBXNativeTarget "AFNetworking Mac Example" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
F8CEEB89142CEC6E00247B03 /* Debug */,
|
||||
F8CEEB8A142CEC6E00247B03 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = F8CEEB61142CEC6E00247B03 /* Project object */;
|
||||
}
|
||||
|
|
@ -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 = "F8CEEB69142CEC6E00247B03"
|
||||
BuildableName = "AFNetworking Mac Example.app"
|
||||
BlueprintName = "AFNetworking Mac Example"
|
||||
ReferencedContainer = "container:AFNetworking Mac 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 = "F8CEEB69142CEC6E00247B03"
|
||||
BuildableName = "AFNetworking Mac Example.app"
|
||||
BlueprintName = "AFNetworking Mac Example"
|
||||
ReferencedContainer = "container:AFNetworking Mac Example.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Release"
|
||||
debugDocumentVersioning = "YES">
|
||||
<BuildableProductRunnable>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "F8CEEB69142CEC6E00247B03"
|
||||
BuildableName = "AFNetworking Mac Example.app"
|
||||
BlueprintName = "AFNetworking Mac Example"
|
||||
ReferencedContainer = "container:AFNetworking Mac 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>AFNetworking Mac Example.xcscheme</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>SuppressBuildableAutocreation</key>
|
||||
<dict>
|
||||
<key>F8CEEB69142CEC6E00247B03</key>
|
||||
<dict>
|
||||
<key>primary</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
//
|
||||
// AFNetworking_Mac_ExampleAppDelegate.h
|
||||
// AFNetworking Mac Example
|
||||
//
|
||||
// Created by Mattt Thompson on 11/09/23.
|
||||
// Copyright 2011年 Gowalla. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@interface AFNetworking_Mac_ExampleAppDelegate : NSObject <NSApplicationDelegate> {
|
||||
NSWindow *_window;
|
||||
}
|
||||
|
||||
@property (strong) IBOutlet NSWindow *window;
|
||||
|
||||
@end
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
//
|
||||
// AFNetworking_Mac_ExampleAppDelegate.m
|
||||
// AFNetworking Mac Example
|
||||
//
|
||||
// Created by Mattt Thompson on 11/09/23.
|
||||
// Copyright 2011年 Gowalla. All rights reserved.
|
||||
//
|
||||
|
||||
#import "AFNetworking_Mac_ExampleAppDelegate.h"
|
||||
|
||||
@implementation AFNetworking_Mac_ExampleAppDelegate
|
||||
|
||||
@synthesize window = _window;
|
||||
|
||||
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
|
||||
{
|
||||
// Insert code here to initialize your application
|
||||
}
|
||||
|
||||
@end
|
||||
36
Mac Example/AFNetworking Mac Example/Info.plist
Normal file
36
Mac Example/AFNetworking Mac Example/Info.plist
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?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>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string></string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.alamofire.${PRODUCT_NAME:rfc1034identifier}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
<string>public.app-category.utilities</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright © 2011 Gowalla. All rights reserved.</string>
|
||||
<key>NSMainNibFile</key>
|
||||
<string>MainMenu</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
</dict>
|
||||
</plist>
|
||||
7
Mac Example/AFNetworking Mac Example/Prefix.pch
Normal file
7
Mac Example/AFNetworking Mac Example/Prefix.pch
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
//
|
||||
// Prefix header for all source files of the 'AFNetworking Mac Example' target in the 'AFNetworking Mac Example' project
|
||||
//
|
||||
|
||||
#ifdef __OBJC__
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#endif
|
||||
29
Mac Example/AFNetworking Mac Example/en.lproj/Credits.rtf
Normal file
29
Mac Example/AFNetworking Mac Example/en.lproj/Credits.rtf
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
{\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;}
|
||||
{\colortbl;\red255\green255\blue255;}
|
||||
\paperw9840\paperh8400
|
||||
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
|
||||
|
||||
\f0\b\fs24 \cf0 Engineering:
|
||||
\b0 \
|
||||
Some people\
|
||||
\
|
||||
|
||||
\b Human Interface Design:
|
||||
\b0 \
|
||||
Some other people\
|
||||
\
|
||||
|
||||
\b Testing:
|
||||
\b0 \
|
||||
Hopefully not nobody\
|
||||
\
|
||||
|
||||
\b Documentation:
|
||||
\b0 \
|
||||
Whoever\
|
||||
\
|
||||
|
||||
\b With special thanks to:
|
||||
\b0 \
|
||||
Mom\
|
||||
}
|
||||
5627
Mac Example/AFNetworking Mac Example/en.lproj/MainMenu.xib
Normal file
5627
Mac Example/AFNetworking Mac Example/en.lproj/MainMenu.xib
Normal file
File diff suppressed because it is too large
Load diff
14
Mac Example/AFNetworking Mac Example/main.m
Normal file
14
Mac Example/AFNetworking Mac Example/main.m
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
//
|
||||
// main.m
|
||||
// AFNetworking Mac Example
|
||||
//
|
||||
// Created by Mattt Thompson on 11/09/23.
|
||||
// Copyright 2011年 Gowalla. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
return NSApplicationMain(argc, (const char **)argv);
|
||||
}
|
||||
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 5.6 KiB |
251
iOS Example/Vendor/JSONKit/JSONKit.h
vendored
Normal file
251
iOS Example/Vendor/JSONKit/JSONKit.h
vendored
Normal file
|
|
@ -0,0 +1,251 @@
|
|||
//
|
||||
// JSONKit.h
|
||||
// http://github.com/johnezang/JSONKit
|
||||
// Dual licensed under either the terms of the BSD License, or alternatively
|
||||
// under the terms of the Apache License, Version 2.0, as specified below.
|
||||
//
|
||||
|
||||
/*
|
||||
Copyright (c) 2011, John Engelhart
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of the Zang Industries nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2011 John Engelhart
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <limits.h>
|
||||
#include <TargetConditionals.h>
|
||||
#include <AvailabilityMacros.h>
|
||||
|
||||
#ifdef __OBJC__
|
||||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSData.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSError.h>
|
||||
#import <Foundation/NSObjCRuntime.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#endif // __OBJC__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
// For Mac OS X < 10.5.
|
||||
#ifndef NSINTEGER_DEFINED
|
||||
#define NSINTEGER_DEFINED
|
||||
#if defined(__LP64__) || defined(NS_BUILD_32_LIKE_64)
|
||||
typedef long NSInteger;
|
||||
typedef unsigned long NSUInteger;
|
||||
#define NSIntegerMin LONG_MIN
|
||||
#define NSIntegerMax LONG_MAX
|
||||
#define NSUIntegerMax ULONG_MAX
|
||||
#else // defined(__LP64__) || defined(NS_BUILD_32_LIKE_64)
|
||||
typedef int NSInteger;
|
||||
typedef unsigned int NSUInteger;
|
||||
#define NSIntegerMin INT_MIN
|
||||
#define NSIntegerMax INT_MAX
|
||||
#define NSUIntegerMax UINT_MAX
|
||||
#endif // defined(__LP64__) || defined(NS_BUILD_32_LIKE_64)
|
||||
#endif // NSINTEGER_DEFINED
|
||||
|
||||
|
||||
#ifndef _JSONKIT_H_
|
||||
#define _JSONKIT_H_
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ >= 4) && defined(__APPLE_CC__) && (__APPLE_CC__ >= 5465)
|
||||
#define JK_DEPRECATED_ATTRIBUTE __attribute__((deprecated))
|
||||
#else
|
||||
#define JK_DEPRECATED_ATTRIBUTE
|
||||
#endif
|
||||
|
||||
#define JSONKIT_VERSION_MAJOR 1
|
||||
#define JSONKIT_VERSION_MINOR 4
|
||||
|
||||
typedef NSUInteger JKFlags;
|
||||
|
||||
/*
|
||||
JKParseOptionComments : Allow C style // and /_* ... *_/ (without a _, obviously) comments in JSON.
|
||||
JKParseOptionUnicodeNewlines : Allow Unicode recommended (?:\r\n|[\n\v\f\r\x85\p{Zl}\p{Zp}]) newlines.
|
||||
JKParseOptionLooseUnicode : Normally the decoder will stop with an error at any malformed Unicode.
|
||||
This option allows JSON with malformed Unicode to be parsed without reporting an error.
|
||||
Any malformed Unicode is replaced with \uFFFD, or "REPLACEMENT CHARACTER".
|
||||
*/
|
||||
|
||||
enum {
|
||||
JKParseOptionNone = 0,
|
||||
JKParseOptionStrict = 0,
|
||||
JKParseOptionComments = (1 << 0),
|
||||
JKParseOptionUnicodeNewlines = (1 << 1),
|
||||
JKParseOptionLooseUnicode = (1 << 2),
|
||||
JKParseOptionPermitTextAfterValidJSON = (1 << 3),
|
||||
JKParseOptionValidFlags = (JKParseOptionComments | JKParseOptionUnicodeNewlines | JKParseOptionLooseUnicode | JKParseOptionPermitTextAfterValidJSON),
|
||||
};
|
||||
typedef JKFlags JKParseOptionFlags;
|
||||
|
||||
enum {
|
||||
JKSerializeOptionNone = 0,
|
||||
JKSerializeOptionPretty = (1 << 0),
|
||||
JKSerializeOptionEscapeUnicode = (1 << 1),
|
||||
JKSerializeOptionEscapeForwardSlashes = (1 << 4),
|
||||
JKSerializeOptionValidFlags = (JKSerializeOptionPretty | JKSerializeOptionEscapeUnicode | JKSerializeOptionEscapeForwardSlashes),
|
||||
};
|
||||
typedef JKFlags JKSerializeOptionFlags;
|
||||
|
||||
#ifdef __OBJC__
|
||||
|
||||
typedef struct JKParseState JKParseState; // Opaque internal, private type.
|
||||
|
||||
// As a general rule of thumb, if you use a method that doesn't accept a JKParseOptionFlags argument, it defaults to JKParseOptionStrict
|
||||
|
||||
@interface JSONDecoder : NSObject {
|
||||
JKParseState *parseState;
|
||||
}
|
||||
+ (id)decoder;
|
||||
+ (id)decoderWithParseOptions:(JKParseOptionFlags)parseOptionFlags;
|
||||
- (id)initWithParseOptions:(JKParseOptionFlags)parseOptionFlags;
|
||||
- (void)clearCache;
|
||||
|
||||
// The parse... methods were deprecated in v1.4 in favor of the v1.4 objectWith... methods.
|
||||
- (id)parseUTF8String:(const unsigned char *)string length:(size_t)length JK_DEPRECATED_ATTRIBUTE; // Deprecated in JSONKit v1.4. Use objectWithUTF8String:length: instead.
|
||||
- (id)parseUTF8String:(const unsigned char *)string length:(size_t)length error:(NSError **)error JK_DEPRECATED_ATTRIBUTE; // Deprecated in JSONKit v1.4. Use objectWithUTF8String:length:error: instead.
|
||||
// The NSData MUST be UTF8 encoded JSON.
|
||||
- (id)parseJSONData:(NSData *)jsonData JK_DEPRECATED_ATTRIBUTE; // Deprecated in JSONKit v1.4. Use objectWithData: instead.
|
||||
- (id)parseJSONData:(NSData *)jsonData error:(NSError **)error JK_DEPRECATED_ATTRIBUTE; // Deprecated in JSONKit v1.4. Use objectWithData:error: instead.
|
||||
|
||||
// Methods that return immutable collection objects.
|
||||
- (id)objectWithUTF8String:(const unsigned char *)string length:(NSUInteger)length;
|
||||
- (id)objectWithUTF8String:(const unsigned char *)string length:(NSUInteger)length error:(NSError **)error;
|
||||
// The NSData MUST be UTF8 encoded JSON.
|
||||
- (id)objectWithData:(NSData *)jsonData;
|
||||
- (id)objectWithData:(NSData *)jsonData error:(NSError **)error;
|
||||
|
||||
// Methods that return mutable collection objects.
|
||||
- (id)mutableObjectWithUTF8String:(const unsigned char *)string length:(NSUInteger)length;
|
||||
- (id)mutableObjectWithUTF8String:(const unsigned char *)string length:(NSUInteger)length error:(NSError **)error;
|
||||
// The NSData MUST be UTF8 encoded JSON.
|
||||
- (id)mutableObjectWithData:(NSData *)jsonData;
|
||||
- (id)mutableObjectWithData:(NSData *)jsonData error:(NSError **)error;
|
||||
|
||||
@end
|
||||
|
||||
////////////
|
||||
#pragma mark Deserializing methods
|
||||
////////////
|
||||
|
||||
@interface NSString (JSONKitDeserializing)
|
||||
- (id)objectFromJSONString;
|
||||
- (id)objectFromJSONStringWithParseOptions:(JKParseOptionFlags)parseOptionFlags;
|
||||
- (id)objectFromJSONStringWithParseOptions:(JKParseOptionFlags)parseOptionFlags error:(NSError **)error;
|
||||
- (id)mutableObjectFromJSONString;
|
||||
- (id)mutableObjectFromJSONStringWithParseOptions:(JKParseOptionFlags)parseOptionFlags;
|
||||
- (id)mutableObjectFromJSONStringWithParseOptions:(JKParseOptionFlags)parseOptionFlags error:(NSError **)error;
|
||||
@end
|
||||
|
||||
@interface NSData (JSONKitDeserializing)
|
||||
// The NSData MUST be UTF8 encoded JSON.
|
||||
- (id)objectFromJSONData;
|
||||
- (id)objectFromJSONDataWithParseOptions:(JKParseOptionFlags)parseOptionFlags;
|
||||
- (id)objectFromJSONDataWithParseOptions:(JKParseOptionFlags)parseOptionFlags error:(NSError **)error;
|
||||
- (id)mutableObjectFromJSONData;
|
||||
- (id)mutableObjectFromJSONDataWithParseOptions:(JKParseOptionFlags)parseOptionFlags;
|
||||
- (id)mutableObjectFromJSONDataWithParseOptions:(JKParseOptionFlags)parseOptionFlags error:(NSError **)error;
|
||||
@end
|
||||
|
||||
////////////
|
||||
#pragma mark Serializing methods
|
||||
////////////
|
||||
|
||||
@interface NSString (JSONKitSerializing)
|
||||
// Convenience methods for those that need to serialize the receiving NSString (i.e., instead of having to serialize a NSArray with a single NSString, you can "serialize to JSON" just the NSString).
|
||||
// Normally, a string that is serialized to JSON has quotation marks surrounding it, which you may or may not want when serializing a single string, and can be controlled with includeQuotes:
|
||||
// includeQuotes:YES `a "test"...` -> `"a \"test\"..."`
|
||||
// includeQuotes:NO `a "test"...` -> `a \"test\"...`
|
||||
- (NSData *)JSONData; // Invokes JSONDataWithOptions:JKSerializeOptionNone includeQuotes:YES
|
||||
- (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions includeQuotes:(BOOL)includeQuotes error:(NSError **)error;
|
||||
- (NSString *)JSONString; // Invokes JSONStringWithOptions:JKSerializeOptionNone includeQuotes:YES
|
||||
- (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions includeQuotes:(BOOL)includeQuotes error:(NSError **)error;
|
||||
@end
|
||||
|
||||
@interface NSArray (JSONKitSerializing)
|
||||
- (NSData *)JSONData;
|
||||
- (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions error:(NSError **)error;
|
||||
- (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingDelegate:(id)delegate selector:(SEL)selector error:(NSError **)error;
|
||||
- (NSString *)JSONString;
|
||||
- (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions error:(NSError **)error;
|
||||
- (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingDelegate:(id)delegate selector:(SEL)selector error:(NSError **)error;
|
||||
@end
|
||||
|
||||
@interface NSDictionary (JSONKitSerializing)
|
||||
- (NSData *)JSONData;
|
||||
- (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions error:(NSError **)error;
|
||||
- (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingDelegate:(id)delegate selector:(SEL)selector error:(NSError **)error;
|
||||
- (NSString *)JSONString;
|
||||
- (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions error:(NSError **)error;
|
||||
- (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingDelegate:(id)delegate selector:(SEL)selector error:(NSError **)error;
|
||||
@end
|
||||
|
||||
#ifdef __BLOCKS__
|
||||
|
||||
@interface NSArray (JSONKitSerializingBlockAdditions)
|
||||
- (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingBlock:(id(^)(id object))block error:(NSError **)error;
|
||||
- (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingBlock:(id(^)(id object))block error:(NSError **)error;
|
||||
@end
|
||||
|
||||
@interface NSDictionary (JSONKitSerializingBlockAdditions)
|
||||
- (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingBlock:(id(^)(id object))block error:(NSError **)error;
|
||||
- (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingBlock:(id(^)(id object))block error:(NSError **)error;
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif // __OBJC__
|
||||
|
||||
#endif // _JSONKIT_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
3011
iOS Example/Vendor/JSONKit/JSONKit.m
vendored
Normal file
3011
iOS Example/Vendor/JSONKit/JSONKit.m
vendored
Normal file
File diff suppressed because it is too large
Load diff
83
iOS Example/Vendor/TTT/TTTLocationFormatter.h
vendored
Normal file
83
iOS Example/Vendor/TTT/TTTLocationFormatter.h
vendored
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
// TTTLocationFormatter.h
|
||||
//
|
||||
// Copyright (c) 2011 Mattt Thompson (http://mattt.me)
|
||||
//
|
||||
// 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>
|
||||
|
||||
typedef enum {
|
||||
TTTNorthDirection,
|
||||
TTTNortheastDirection,
|
||||
TTTEastDirection,
|
||||
TTTSoutheastDirection,
|
||||
TTTSouthDirection,
|
||||
TTTSouthwestDirection,
|
||||
TTTWestDirection,
|
||||
TTTNorthwestDirection,
|
||||
} TTTLocationCardinalDirection;
|
||||
|
||||
extern TTTLocationCardinalDirection TTTLocationCardinalDirectionFromBearing(CLLocationDegrees bearing);
|
||||
|
||||
typedef enum {
|
||||
TTTCoordinateLatLngOrder = 0,
|
||||
TTTCoordinateLngLatOrder,
|
||||
} TTTLocationFormatterCoordinateOrder;
|
||||
|
||||
typedef enum {
|
||||
TTTBearingWordStyle = 0,
|
||||
TTTBearingAbbreviationWordStyle,
|
||||
TTTBearingNumericStyle,
|
||||
} TTTLocationFormatterBearingStyle;
|
||||
|
||||
typedef enum {
|
||||
TTTMetricSystem = 0,
|
||||
TTTImperialSystem,
|
||||
} TTTLocationUnitSystem;
|
||||
|
||||
@interface TTTLocationFormatter : NSFormatter {
|
||||
TTTLocationFormatterCoordinateOrder _coordinateOrder;
|
||||
TTTLocationFormatterBearingStyle _bearingStyle;
|
||||
TTTLocationUnitSystem _unitSystem;
|
||||
NSNumberFormatter *_numberFormatter;
|
||||
}
|
||||
|
||||
@property (readonly, nonatomic, retain) NSNumberFormatter *numberFormatter;
|
||||
|
||||
- (NSString *)stringFromCoordinate:(CLLocationCoordinate2D)coordinate;
|
||||
- (NSString *)stringFromLocation:(CLLocation *)location;
|
||||
- (NSString *)stringFromDistance:(CLLocationDistance)distance;
|
||||
- (NSString *)stringFromBearing:(CLLocationDegrees)bearing;
|
||||
- (NSString *)stringFromSpeed:(CLLocationSpeed)speed;
|
||||
- (NSString *)stringFromDistanceFromLocation:(CLLocation *)originLocation toLocation:(CLLocation *)destinationLocation;
|
||||
- (NSString *)stringFromBearingFromLocation:(CLLocation *)originLocation toLocation:(CLLocation *)destinationLocation;
|
||||
- (NSString *)stringFromDistanceAndBearingFromLocation:(CLLocation *)originLocation toLocation:(CLLocation *)destinationLocation;
|
||||
- (NSString *)stringFromVelocityFromLocation:(CLLocation *)originLocation toLocation:(CLLocation *)destinationLocation atSpeed:(CLLocationSpeed)speed;
|
||||
|
||||
- (TTTLocationFormatterCoordinateOrder)coordinateOrder;
|
||||
- (void)setCoordinateOrder:(TTTLocationFormatterCoordinateOrder)coordinateOrder;
|
||||
|
||||
- (TTTLocationFormatterBearingStyle)bearingStyle;
|
||||
- (void)setBearingStyle:(TTTLocationFormatterBearingStyle)bearingStyle;
|
||||
|
||||
- (TTTLocationUnitSystem)unitSystem;
|
||||
- (void)setUnitSystem:(TTTLocationUnitSystem)unitSystem;
|
||||
|
||||
@end
|
||||
299
iOS Example/Vendor/TTT/TTTLocationFormatter.m
vendored
Normal file
299
iOS Example/Vendor/TTT/TTTLocationFormatter.m
vendored
Normal file
|
|
@ -0,0 +1,299 @@
|
|||
// TTTLocationFormatter.m
|
||||
//
|
||||
// Copyright (c) 2011 Mattt Thompson (http://mattt.me)
|
||||
//
|
||||
// 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 "TTTLocationFormatter.h"
|
||||
|
||||
static double const kTTTMetersToKilometersCoefficient = 0.001;
|
||||
static double const kTTTMetersToFeetCoefficient = 3.2808399;
|
||||
static double const kTTTMetersToYardsCoefficient = 1.0936133;
|
||||
static double const kTTTMetersToMilesCoefficient = 0.000621371192;
|
||||
|
||||
static inline double CLLocationDistanceToKilometers(CLLocationDistance distance) {
|
||||
return distance * kTTTMetersToKilometersCoefficient;
|
||||
}
|
||||
|
||||
static inline double CLLocationDistanceToFeet(CLLocationDistance distance) {
|
||||
return distance * kTTTMetersToFeetCoefficient;
|
||||
}
|
||||
|
||||
static inline double CLLocationDistanceToYards(CLLocationDistance distance) {
|
||||
return distance * kTTTMetersToYardsCoefficient;
|
||||
}
|
||||
|
||||
static inline double CLLocationDistanceToMiles(CLLocationDistance distance) {
|
||||
return distance * kTTTMetersToMilesCoefficient;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
static inline double DEG2RAD(double degrees) {
|
||||
return degrees * M_PI / 180;
|
||||
}
|
||||
|
||||
static inline double RAD2DEG(double radians) {
|
||||
return radians * 180 / M_PI;
|
||||
}
|
||||
|
||||
static inline CLLocationDegrees CLLocationDegreesBearingBetweenCoordinates(CLLocationCoordinate2D originCoordinate, CLLocationCoordinate2D destinationCoordinate) {
|
||||
double lat1 = DEG2RAD(originCoordinate.latitude);
|
||||
double lon1 = DEG2RAD(originCoordinate.longitude);
|
||||
double lat2 = DEG2RAD(destinationCoordinate.latitude);
|
||||
double lon2 = DEG2RAD(destinationCoordinate.longitude);
|
||||
|
||||
double dLon = lon2 - lon1;
|
||||
double y = sin(dLon) * cos(lat2);
|
||||
double x = cos(lat1) * sin(lat2) - sin(lat1) * cos(lat2) * cos(dLon);
|
||||
double bearing = atan2(y, x) + (2 * M_PI);
|
||||
|
||||
// `atan2` works on a range of -π to 0 to π, so add on 2π and perform a modulo check
|
||||
if (bearing > (2 * M_PI)) {
|
||||
bearing = bearing - (2 * M_PI);
|
||||
}
|
||||
|
||||
return RAD2DEG(bearing);
|
||||
}
|
||||
|
||||
TTTLocationCardinalDirection TTTLocationCardinalDirectionFromBearing(CLLocationDegrees bearing) {
|
||||
if(bearing > 337.5) {
|
||||
return TTTNorthDirection;
|
||||
} else if(bearing > 292.5) {
|
||||
return TTTNorthwestDirection;
|
||||
} else if(bearing > 247.5) {
|
||||
return TTTWestDirection;
|
||||
} else if(bearing > 202.5) {
|
||||
return TTTSouthwestDirection;
|
||||
} else if(bearing > 157.5) {
|
||||
return TTTSouthDirection;
|
||||
} else if(bearing > 112.5) {
|
||||
return TTTSoutheastDirection;
|
||||
} else if(bearing > 67.5) {
|
||||
return TTTEastDirection;
|
||||
} else if(bearing > 22.5) {
|
||||
return TTTNortheastDirection;
|
||||
} else {
|
||||
return TTTNorthDirection;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
static double const kTTTMetersPerSecondToKilometersPerHourCoefficient = 3.6;
|
||||
static double const kTTTMetersPerSecondToFeetPerSecondCoefficient = 3.2808399;
|
||||
static double const kTTTMetersPerSecondToMilesPerHourCoefficient = 2.23693629;
|
||||
|
||||
static inline double CLLocationSpeedToKilometersPerHour(CLLocationSpeed speed) {
|
||||
return speed * kTTTMetersPerSecondToKilometersPerHourCoefficient;
|
||||
}
|
||||
|
||||
static inline double CLLocationSpeedToFeetPerSecond(CLLocationSpeed speed) {
|
||||
return speed * kTTTMetersPerSecondToFeetPerSecondCoefficient;
|
||||
}
|
||||
|
||||
static inline double CLLocationSpeedToMilesPerHour(CLLocationSpeed speed) {
|
||||
return speed * kTTTMetersPerSecondToMilesPerHourCoefficient;
|
||||
}
|
||||
|
||||
|
||||
@interface TTTLocationFormatter ()
|
||||
@property (readwrite, nonatomic, assign) TTTLocationFormatterCoordinateOrder coordinateOrder;
|
||||
@property (readwrite, nonatomic, assign) TTTLocationFormatterBearingStyle bearingStyle;
|
||||
@property (readwrite, nonatomic, assign) TTTLocationUnitSystem unitSystem;
|
||||
@property (readwrite, nonatomic, retain) NSNumberFormatter *numberFormatter;
|
||||
@end
|
||||
|
||||
@implementation TTTLocationFormatter
|
||||
@synthesize coordinateOrder = _coordinateOrder;
|
||||
@synthesize bearingStyle = _bearingStyle;
|
||||
@synthesize unitSystem = _unitSystem;
|
||||
@synthesize numberFormatter = _numberFormatter;
|
||||
|
||||
- (id)init {
|
||||
self = [super init];
|
||||
if (!self) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
self.coordinateOrder = TTTCoordinateLatLngOrder;
|
||||
self.bearingStyle = TTTBearingWordStyle;
|
||||
self.unitSystem = TTTMetricSystem;
|
||||
|
||||
self.numberFormatter = [[[NSNumberFormatter alloc] init] autorelease];
|
||||
[self.numberFormatter setLocale:[NSLocale currentLocale]];
|
||||
[self.numberFormatter setNumberStyle:NSNumberFormatterDecimalStyle];
|
||||
[self.numberFormatter setMaximumSignificantDigits:2];
|
||||
[self.numberFormatter setUsesSignificantDigits:YES];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSString *)stringFromCoordinate:(CLLocationCoordinate2D)coordinate {
|
||||
return [NSString stringWithFormat:NSLocalizedString(@"(%@, %@)", @"Coordinate format"), [self.numberFormatter stringFromNumber:[NSNumber numberWithDouble:coordinate.latitude]], [self.numberFormatter stringFromNumber:[NSNumber numberWithDouble:coordinate.longitude]], nil];
|
||||
}
|
||||
|
||||
- (NSString *)stringFromLocation:(CLLocation *)location {
|
||||
return [self stringFromCoordinate:location.coordinate];
|
||||
}
|
||||
|
||||
- (NSString *)stringFromDistance:(CLLocationDistance)distance {
|
||||
NSString *distanceString = nil;
|
||||
NSString *unitString = nil;
|
||||
|
||||
switch (self.unitSystem) {
|
||||
case TTTMetricSystem: {
|
||||
double kilometerDistance = CLLocationDistanceToKilometers(distance);
|
||||
if (kilometerDistance > 1) {
|
||||
distanceString = [self.numberFormatter stringFromNumber:[NSNumber numberWithDouble:kilometerDistance]];
|
||||
unitString = NSLocalizedString(@"km", @"Kilometer Unit");
|
||||
} else {
|
||||
double meterDistance = distance;
|
||||
distanceString = [self.numberFormatter stringFromNumber:[NSNumber numberWithDouble:meterDistance]];
|
||||
unitString = NSLocalizedString(@"m", @"Meter Unit");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case TTTImperialSystem: {
|
||||
double feetDistance = CLLocationDistanceToFeet(distance);
|
||||
if (feetDistance < 300) {
|
||||
distanceString = [self.numberFormatter stringFromNumber:[NSNumber numberWithDouble:feetDistance]];
|
||||
unitString = NSLocalizedString(@"ft", @"Feet Unit");
|
||||
} else {
|
||||
double yardDistance = CLLocationDistanceToYards(distance);
|
||||
if (yardDistance < 500) {
|
||||
distanceString = [self.numberFormatter stringFromNumber:[NSNumber numberWithDouble:yardDistance]];
|
||||
unitString = NSLocalizedString(@"yds", @"Yard Unit");
|
||||
} else {
|
||||
double milesDistance = CLLocationDistanceToMiles(distance);
|
||||
distanceString = [self.numberFormatter stringFromNumber:[NSNumber numberWithDouble:milesDistance]];
|
||||
unitString = (milesDistance > 1.0 && milesDistance < 1.1) ? NSLocalizedString(@"mile", @"Mile Unit (Singular)") : NSLocalizedString(@"miles", @"Mile Unit (Plural)");
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return [NSString stringWithFormat:NSLocalizedString(@"%@ %@", @"#{Distance} #{Unit}"), distanceString, unitString];
|
||||
}
|
||||
|
||||
- (NSString *)stringFromBearing:(CLLocationDegrees)bearing {
|
||||
switch (self.bearingStyle) {
|
||||
case TTTBearingWordStyle:
|
||||
switch (TTTLocationCardinalDirectionFromBearing(bearing)) {
|
||||
case TTTNorthDirection:
|
||||
return NSLocalizedString(@"North", @"North Direction");
|
||||
case TTTNortheastDirection:
|
||||
return NSLocalizedString(@"Northeast", @"Northeast Direction");
|
||||
case TTTEastDirection:
|
||||
return NSLocalizedString(@"East", @"East Direction");
|
||||
case TTTSoutheastDirection:
|
||||
return NSLocalizedString(@"Southeast", @"Southeast Direction");
|
||||
case TTTSouthDirection:
|
||||
return NSLocalizedString(@"South", @"South Direction");
|
||||
case TTTSouthwestDirection:
|
||||
return NSLocalizedString(@"Southwest", @"Southwest Direction");
|
||||
case TTTWestDirection:
|
||||
return NSLocalizedString(@"West", @"West Direction");
|
||||
case TTTNorthwestDirection:
|
||||
return NSLocalizedString(@"Northwest", @"Northwest Direction");
|
||||
}
|
||||
break;
|
||||
case TTTBearingAbbreviationWordStyle:
|
||||
switch (TTTLocationCardinalDirectionFromBearing(bearing)) {
|
||||
case TTTNorthDirection:
|
||||
return NSLocalizedString(@"N", @"North Direction Abbreviation");
|
||||
case TTTNortheastDirection:
|
||||
return NSLocalizedString(@"NE", @"Northeast Direction Abbreviation");
|
||||
case TTTEastDirection:
|
||||
return NSLocalizedString(@"E", @"East Direction Abbreviation");
|
||||
case TTTSoutheastDirection:
|
||||
return NSLocalizedString(@"SE", @"Southeast Direction Abbreviation");
|
||||
case TTTSouthDirection:
|
||||
return NSLocalizedString(@"S", @"South Direction Abbreviation");
|
||||
case TTTSouthwestDirection:
|
||||
return NSLocalizedString(@"SW", @"Southwest Direction Abbreviation");
|
||||
case TTTWestDirection:
|
||||
return NSLocalizedString(@"W", @"West Direction Abbreviation");
|
||||
case TTTNorthwestDirection:
|
||||
return NSLocalizedString(@"NW", @"Northwest Direction Abbreviation");;
|
||||
}
|
||||
break;
|
||||
case TTTBearingNumericStyle:
|
||||
return [[self.numberFormatter stringFromNumber:[NSNumber numberWithDouble:bearing]] stringByAppendingString:NSLocalizedString(@"°", @"Degrees Symbol")];
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSString *)stringFromSpeed:(CLLocationSpeed)speed {
|
||||
NSString *speedString = nil;
|
||||
NSString *unitString = nil;
|
||||
|
||||
switch (self.unitSystem) {
|
||||
case TTTMetricSystem: {
|
||||
double metersPerSecondSpeed = speed;
|
||||
double kilometersPerHourSpeed = CLLocationSpeedToKilometersPerHour(speed);
|
||||
|
||||
if (kilometersPerHourSpeed > 1) {
|
||||
speedString = [self.numberFormatter stringFromNumber:[NSNumber numberWithDouble:kilometersPerHourSpeed]];
|
||||
unitString = NSLocalizedString(@"km/h", @"Kilometers Per Hour Unit");
|
||||
} else {
|
||||
speedString = [self.numberFormatter stringFromNumber:[NSNumber numberWithDouble:metersPerSecondSpeed]];
|
||||
unitString = NSLocalizedString(@"m/s", @"Meters Per Second Unit");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case TTTImperialSystem: {
|
||||
double feetPerSecondSpeed = CLLocationSpeedToFeetPerSecond(speed);
|
||||
double milesPerHourSpeed = CLLocationSpeedToMilesPerHour(speed);
|
||||
|
||||
if (milesPerHourSpeed > 1) {
|
||||
speedString = [self.numberFormatter stringFromNumber:[NSNumber numberWithDouble:milesPerHourSpeed]];
|
||||
unitString = NSLocalizedString(@"mph", @"Miles Per Hour Unit");
|
||||
} else {
|
||||
speedString = [self.numberFormatter stringFromNumber:[NSNumber numberWithDouble:feetPerSecondSpeed]];
|
||||
unitString = NSLocalizedString(@"ft/s", @"Feet Per Second Unit");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return [NSString stringWithFormat:NSLocalizedString(@"%@ %@", @"#{Speed} #{Unit}"), speedString, unitString];
|
||||
}
|
||||
|
||||
- (NSString *)stringFromDistanceFromLocation:(CLLocation *)originLocation toLocation:(CLLocation *)destinationLocation {
|
||||
return [self stringFromDistance:[destinationLocation distanceFromLocation:originLocation]];
|
||||
}
|
||||
|
||||
- (NSString *)stringFromBearingFromLocation:(CLLocation *)originLocation toLocation:(CLLocation *)destinationLocation {
|
||||
return [self stringFromBearing:CLLocationDegreesBearingBetweenCoordinates(originLocation.coordinate, destinationLocation.coordinate)];
|
||||
}
|
||||
|
||||
- (NSString *)stringFromDistanceAndBearingFromLocation:(CLLocation *)originLocation toLocation:(CLLocation *)destinationLocation {
|
||||
return [NSString stringWithFormat:NSLocalizedString(@"%@ %@", @"#{Dimensional Quantity} #{Direction}"), [self stringFromDistanceFromLocation:originLocation toLocation:destinationLocation], [self stringFromBearingFromLocation:originLocation toLocation:destinationLocation]];
|
||||
}
|
||||
|
||||
- (NSString *)stringFromVelocityFromLocation:(CLLocation *)originLocation toLocation:(CLLocation *)destinationLocation atSpeed:(CLLocationSpeed)speed {
|
||||
return [NSString stringWithFormat:NSLocalizedString(@"%@ %@", @"#{Dimensional Quantity} #{Direction}"), [self stringFromSpeed:speed], [self stringFromBearingFromLocation:originLocation toLocation:destinationLocation]];
|
||||
}
|
||||
|
||||
@end
|
||||
Loading…
Add table
Reference in a new issue