Changing iOS example to Twitter Client

This commit is contained in:
Mattt Thompson 2012-03-12 22:04:39 -07:00
parent f11c93d446
commit 0481d55949
25 changed files with 533 additions and 4228 deletions

View file

@ -7,68 +7,38 @@
objects = {
/* Begin PBXBuildFile section */
3ACFD84015037DAB00FF5F0F /* JSONKit.m in Sources */ = {isa = PBXBuildFile; fileRef = F8D25D111396A9C400CF3BD6 /* JSONKit.m */; };
F8689A9914CC9F5E0087F357 /* AFJSONUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = F8689A9814CC9F5E0087F357 /* AFJSONUtilities.m */; };
F86E5529143A28F3002B438C /* AFURLConnectionOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F86E5528143A28F3002B438C /* AFURLConnectionOperation.m */; };
F874B5D913E0AA6500B28E3E /* AFHTTPRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F874B5C913E0AA6500B28E3E /* AFHTTPRequestOperation.m */; };
F874B5DB13E0AA6500B28E3E /* AFImageRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F874B5CB13E0AA6500B28E3E /* AFImageRequestOperation.m */; };
F874B5DC13E0AA6500B28E3E /* AFJSONRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F874B5CC13E0AA6500B28E3E /* AFJSONRequestOperation.m */; };
F874B5DD13E0AA6500B28E3E /* AFNetworkActivityIndicatorManager.m in Sources */ = {isa = PBXBuildFile; fileRef = F874B5CD13E0AA6500B28E3E /* AFNetworkActivityIndicatorManager.m */; };
F874B5E013E0AA6500B28E3E /* UIImageView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = F874B5D013E0AA6500B28E3E /* UIImageView+AFNetworking.m */; };
F8D0701B14310F4A00653FD3 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8E469E213957DF700DB05C8 /* SystemConfiguration.framework */; };
F8D0701C14310F4F00653FD3 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8E469E013957DF100DB05C8 /* Security.framework */; };
F8D25D191396A9D300CF3BD6 /* placeholder-stamp.png in Resources */ = {isa = PBXBuildFile; fileRef = F8D25D171396A9D300CF3BD6 /* placeholder-stamp.png */; };
F8D25D1A1396A9D300CF3BD6 /* placeholder-stamp@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = F8D25D181396A9D300CF3BD6 /* placeholder-stamp@2x.png */; };
F8DA09D21396ABED0057D0CC /* AFGowallaAPIClient.m in Sources */ = {isa = PBXBuildFile; fileRef = F8D25D1D1396A9DE00CF3BD6 /* AFGowallaAPIClient.m */; };
F8DA09D41396ABED0057D0CC /* NearbySpotsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F8DA09C81396AB690057D0CC /* NearbySpotsViewController.m */; };
F8DA09D51396ABED0057D0CC /* Spot.m in Sources */ = {isa = PBXBuildFile; fileRef = F8DA09CB1396AB690057D0CC /* Spot.m */; };
F8DA09D61396ABED0057D0CC /* SpotTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F8DA09CE1396AB690057D0CC /* SpotTableViewCell.m */; };
F8DA09E21396ABED0057D0CC /* TTTLocationFormatter.m in Sources */ = {isa = PBXBuildFile; fileRef = F8D25D141396A9C400CF3BD6 /* TTTLocationFormatter.m */; };
F8DA09E41396AC040057D0CC /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = F8DA09E31396AC040057D0CC /* main.m */; };
F8DA09E81396AC220057D0CC /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = F8DA09E71396AC220057D0CC /* AppDelegate.m */; };
F8E469651395739D00DB05C8 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8E469641395739D00DB05C8 /* UIKit.framework */; };
F8E469671395739D00DB05C8 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8E469661395739D00DB05C8 /* Foundation.framework */; };
F8E469691395739D00DB05C8 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8E469681395739D00DB05C8 /* CoreGraphics.framework */; };
F8E469DF13957DD500DB05C8 /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8E469DE13957DD500DB05C8 /* CoreLocation.framework */; };
F8F4B16E143CD1420064C9E6 /* AFPropertyListRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F8F4B16D143CD1410064C9E6 /* AFPropertyListRequestOperation.m */; };
F8F4B17F143E07030064C9E6 /* AFXMLRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F8F4B17E143E07030064C9E6 /* AFXMLRequestOperation.m */; };
F8F6E8DA1463424800AD016F /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = F8F6E8D61463424800AD016F /* Default.png */; };
F8F6E8DB1463424800AD016F /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = F8F6E8D71463424800AD016F /* Default@2x.png */; };
F8F6E8DC1463424800AD016F /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = F8F6E8D81463424800AD016F /* Icon.png */; };
F8F6E8DD1463424800AD016F /* Icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = F8F6E8D91463424800AD016F /* Icon@2x.png */; };
F8FBFA98142AA239001409DB /* AFHTTPClient.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FBFA97142AA238001409DB /* AFHTTPClient.m */; };
F8FA9491150EF8C100ED4EAD /* AFTwitterAPIClient.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA9490150EF8C100ED4EAD /* AFTwitterAPIClient.m */; };
F8FA9494150EF97E00ED4EAD /* Tweet.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA9493150EF97E00ED4EAD /* Tweet.m */; };
F8FA9497150EF98800ED4EAD /* User.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA9496150EF98800ED4EAD /* User.m */; };
F8FA949A150EF9DA00ED4EAD /* PublicTimelineViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA9499150EF9DA00ED4EAD /* PublicTimelineViewController.m */; };
F8FA94B1150EFEC100ED4EAD /* AFHTTPClient.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA949D150EFEC100ED4EAD /* AFHTTPClient.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
F8FA94B2150EFEC100ED4EAD /* AFHTTPRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA949F150EFEC100ED4EAD /* AFHTTPRequestOperation.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
F8FA94B3150EFEC100ED4EAD /* AFImageRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA94A1150EFEC100ED4EAD /* AFImageRequestOperation.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
F8FA94B4150EFEC100ED4EAD /* AFJSONRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA94A3150EFEC100ED4EAD /* AFJSONRequestOperation.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
F8FA94B5150EFEC100ED4EAD /* AFJSONUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA94A5150EFEC100ED4EAD /* AFJSONUtilities.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
F8FA94B6150EFEC100ED4EAD /* AFNetworkActivityIndicatorManager.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA94A7150EFEC100ED4EAD /* AFNetworkActivityIndicatorManager.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
F8FA94B7150EFEC100ED4EAD /* AFPropertyListRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA94AA150EFEC100ED4EAD /* AFPropertyListRequestOperation.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
F8FA94B8150EFEC100ED4EAD /* AFURLConnectionOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA94AC150EFEC100ED4EAD /* AFURLConnectionOperation.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
F8FA94B9150EFEC100ED4EAD /* AFXMLRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA94AE150EFEC100ED4EAD /* AFXMLRequestOperation.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
F8FA94BA150EFEC100ED4EAD /* UIImageView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA94B0150EFEC100ED4EAD /* UIImageView+AFNetworking.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
F8FA94C1150F019100ED4EAD /* TweetTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F8FA94C0150F019100ED4EAD /* TweetTableViewCell.m */; };
F8FA94D0150F094D00ED4EAD /* profile-image-placeholder.png in Resources */ = {isa = PBXBuildFile; fileRef = F8FA94CC150F094D00ED4EAD /* profile-image-placeholder.png */; };
F8FA94D1150F094D00ED4EAD /* profile-image-placeholder@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = F8FA94CD150F094D00ED4EAD /* profile-image-placeholder@2x.png */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
F8323C941455C03400190CCB /* AFJSONUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AFJSONUtilities.h; path = ../AFNetworking/AFJSONUtilities.h; sourceTree = "<group>"; };
F8689A9814CC9F5E0087F357 /* AFJSONUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AFJSONUtilities.m; path = ../AFNetworking/AFJSONUtilities.m; sourceTree = "<group>"; };
F86E5527143A28F3002B438C /* AFURLConnectionOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AFURLConnectionOperation.h; path = ../AFNetworking/AFURLConnectionOperation.h; sourceTree = "<group>"; };
F86E5528143A28F3002B438C /* AFURLConnectionOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AFURLConnectionOperation.m; path = ../AFNetworking/AFURLConnectionOperation.m; sourceTree = "<group>"; };
F874B5C913E0AA6500B28E3E /* AFHTTPRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AFHTTPRequestOperation.m; path = ../AFNetworking/AFHTTPRequestOperation.m; sourceTree = "<group>"; };
F874B5CB13E0AA6500B28E3E /* AFImageRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AFImageRequestOperation.m; path = ../AFNetworking/AFImageRequestOperation.m; sourceTree = "<group>"; };
F874B5CC13E0AA6500B28E3E /* AFJSONRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AFJSONRequestOperation.m; path = ../AFNetworking/AFJSONRequestOperation.m; sourceTree = "<group>"; };
F874B5CD13E0AA6500B28E3E /* AFNetworkActivityIndicatorManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AFNetworkActivityIndicatorManager.m; path = ../AFNetworking/AFNetworkActivityIndicatorManager.m; sourceTree = "<group>"; };
F874B5D013E0AA6500B28E3E /* UIImageView+AFNetworking.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIImageView+AFNetworking.m"; path = "../AFNetworking/UIImageView+AFNetworking.m"; sourceTree = "<group>"; };
F874B5D113E0AA6500B28E3E /* AFHTTPRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AFHTTPRequestOperation.h; path = ../AFNetworking/AFHTTPRequestOperation.h; sourceTree = "<group>"; };
F874B5D313E0AA6500B28E3E /* AFImageRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AFImageRequestOperation.h; path = ../AFNetworking/AFImageRequestOperation.h; sourceTree = "<group>"; };
F874B5D413E0AA6500B28E3E /* AFJSONRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AFJSONRequestOperation.h; path = ../AFNetworking/AFJSONRequestOperation.h; sourceTree = "<group>"; };
F874B5D513E0AA6500B28E3E /* AFNetworkActivityIndicatorManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AFNetworkActivityIndicatorManager.h; path = ../AFNetworking/AFNetworkActivityIndicatorManager.h; sourceTree = "<group>"; };
F874B5D813E0AA6500B28E3E /* UIImageView+AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIImageView+AFNetworking.h"; path = "../AFNetworking/UIImageView+AFNetworking.h"; sourceTree = "<group>"; };
F8D25D101396A9C400CF3BD6 /* JSONKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSONKit.h; sourceTree = "<group>"; };
F8D25D111396A9C400CF3BD6 /* JSONKit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JSONKit.m; sourceTree = "<group>"; };
F8D25D131396A9C400CF3BD6 /* TTTLocationFormatter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TTTLocationFormatter.h; sourceTree = "<group>"; };
F8D25D141396A9C400CF3BD6 /* TTTLocationFormatter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TTTLocationFormatter.m; sourceTree = "<group>"; };
F8D25D171396A9D300CF3BD6 /* placeholder-stamp.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "placeholder-stamp.png"; path = "Images/placeholder-stamp.png"; sourceTree = SOURCE_ROOT; };
F8D25D181396A9D300CF3BD6 /* placeholder-stamp@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "placeholder-stamp@2x.png"; path = "Images/placeholder-stamp@2x.png"; sourceTree = SOURCE_ROOT; };
F8D25D1B1396A9DE00CF3BD6 /* AFGowallaAPIClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AFGowallaAPIClient.h; path = Classes/AFGowallaAPIClient.h; sourceTree = "<group>"; };
F8D25D1D1396A9DE00CF3BD6 /* AFGowallaAPIClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AFGowallaAPIClient.m; path = Classes/AFGowallaAPIClient.m; sourceTree = "<group>"; };
F8D7DE781445F354000EF2F3 /* AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AFNetworking.h; path = ../AFNetworking/AFNetworking.h; sourceTree = "<group>"; };
F8DA09C71396AB690057D0CC /* NearbySpotsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NearbySpotsViewController.h; sourceTree = "<group>"; };
F8DA09C81396AB690057D0CC /* NearbySpotsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NearbySpotsViewController.m; sourceTree = "<group>"; };
F8DA09CA1396AB690057D0CC /* Spot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Spot.h; sourceTree = "<group>"; };
F8DA09CB1396AB690057D0CC /* Spot.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Spot.m; sourceTree = "<group>"; };
F8DA09CD1396AB690057D0CC /* SpotTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpotTableViewCell.h; sourceTree = "<group>"; };
F8DA09CE1396AB690057D0CC /* SpotTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SpotTableViewCell.m; sourceTree = "<group>"; };
F8DA09E31396AC040057D0CC /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = SOURCE_ROOT; };
F8DA09E51396AC220057D0CC /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = SOURCE_ROOT; };
F8DA09E61396AC220057D0CC /* Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Prefix.pch; sourceTree = SOURCE_ROOT; };
@ -81,16 +51,43 @@
F8E469DE13957DD500DB05C8 /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; };
F8E469E013957DF100DB05C8 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
F8E469E213957DF700DB05C8 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
F8F4B16C143CD1410064C9E6 /* AFPropertyListRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AFPropertyListRequestOperation.h; path = ../AFNetworking/AFPropertyListRequestOperation.h; sourceTree = "<group>"; };
F8F4B16D143CD1410064C9E6 /* AFPropertyListRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AFPropertyListRequestOperation.m; path = ../AFNetworking/AFPropertyListRequestOperation.m; sourceTree = "<group>"; };
F8F4B17D143E07030064C9E6 /* AFXMLRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AFXMLRequestOperation.h; path = ../AFNetworking/AFXMLRequestOperation.h; sourceTree = "<group>"; };
F8F4B17E143E07030064C9E6 /* AFXMLRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AFXMLRequestOperation.m; path = ../AFNetworking/AFXMLRequestOperation.m; sourceTree = "<group>"; };
F8F6E8D61463424800AD016F /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = SOURCE_ROOT; };
F8F6E8D71463424800AD016F /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = SOURCE_ROOT; };
F8F6E8D81463424800AD016F /* Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Icon.png; sourceTree = SOURCE_ROOT; };
F8F6E8D91463424800AD016F /* Icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon@2x.png"; sourceTree = SOURCE_ROOT; };
F8FBFA96142AA237001409DB /* AFHTTPClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AFHTTPClient.h; path = ../AFNetworking/AFHTTPClient.h; sourceTree = "<group>"; };
F8FBFA97142AA238001409DB /* AFHTTPClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AFHTTPClient.m; path = ../AFNetworking/AFHTTPClient.m; sourceTree = "<group>"; };
F8FA948F150EF8C100ED4EAD /* AFTwitterAPIClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AFTwitterAPIClient.h; path = Classes/AFTwitterAPIClient.h; sourceTree = "<group>"; };
F8FA9490150EF8C100ED4EAD /* AFTwitterAPIClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AFTwitterAPIClient.m; path = Classes/AFTwitterAPIClient.m; sourceTree = "<group>"; };
F8FA9492150EF97E00ED4EAD /* Tweet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Tweet.h; sourceTree = "<group>"; };
F8FA9493150EF97E00ED4EAD /* Tweet.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Tweet.m; sourceTree = "<group>"; };
F8FA9495150EF98800ED4EAD /* User.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = User.h; sourceTree = "<group>"; };
F8FA9496150EF98800ED4EAD /* User.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = User.m; sourceTree = "<group>"; };
F8FA9498150EF9DA00ED4EAD /* PublicTimelineViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PublicTimelineViewController.h; sourceTree = "<group>"; };
F8FA9499150EF9DA00ED4EAD /* PublicTimelineViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PublicTimelineViewController.m; sourceTree = "<group>"; };
F8FA949C150EFEC100ED4EAD /* AFHTTPClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFHTTPClient.h; sourceTree = "<group>"; };
F8FA949D150EFEC100ED4EAD /* AFHTTPClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFHTTPClient.m; sourceTree = "<group>"; };
F8FA949E150EFEC100ED4EAD /* AFHTTPRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFHTTPRequestOperation.h; sourceTree = "<group>"; };
F8FA949F150EFEC100ED4EAD /* AFHTTPRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFHTTPRequestOperation.m; sourceTree = "<group>"; };
F8FA94A0150EFEC100ED4EAD /* AFImageRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFImageRequestOperation.h; sourceTree = "<group>"; };
F8FA94A1150EFEC100ED4EAD /* AFImageRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFImageRequestOperation.m; sourceTree = "<group>"; };
F8FA94A2150EFEC100ED4EAD /* AFJSONRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFJSONRequestOperation.h; sourceTree = "<group>"; };
F8FA94A3150EFEC100ED4EAD /* AFJSONRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFJSONRequestOperation.m; sourceTree = "<group>"; };
F8FA94A4150EFEC100ED4EAD /* AFJSONUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFJSONUtilities.h; sourceTree = "<group>"; };
F8FA94A5150EFEC100ED4EAD /* AFJSONUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFJSONUtilities.m; sourceTree = "<group>"; };
F8FA94A6150EFEC100ED4EAD /* AFNetworkActivityIndicatorManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFNetworkActivityIndicatorManager.h; sourceTree = "<group>"; };
F8FA94A7150EFEC100ED4EAD /* AFNetworkActivityIndicatorManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFNetworkActivityIndicatorManager.m; sourceTree = "<group>"; };
F8FA94A8150EFEC100ED4EAD /* AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFNetworking.h; sourceTree = "<group>"; };
F8FA94A9150EFEC100ED4EAD /* AFPropertyListRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFPropertyListRequestOperation.h; sourceTree = "<group>"; };
F8FA94AA150EFEC100ED4EAD /* AFPropertyListRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFPropertyListRequestOperation.m; sourceTree = "<group>"; };
F8FA94AB150EFEC100ED4EAD /* AFURLConnectionOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFURLConnectionOperation.h; sourceTree = "<group>"; };
F8FA94AC150EFEC100ED4EAD /* AFURLConnectionOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFURLConnectionOperation.m; sourceTree = "<group>"; };
F8FA94AD150EFEC100ED4EAD /* AFXMLRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFXMLRequestOperation.h; sourceTree = "<group>"; };
F8FA94AE150EFEC100ED4EAD /* AFXMLRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFXMLRequestOperation.m; sourceTree = "<group>"; };
F8FA94AF150EFEC100ED4EAD /* UIImageView+AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImageView+AFNetworking.h"; sourceTree = "<group>"; };
F8FA94B0150EFEC100ED4EAD /* UIImageView+AFNetworking.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImageView+AFNetworking.m"; sourceTree = "<group>"; };
F8FA94BF150F019100ED4EAD /* TweetTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TweetTableViewCell.h; sourceTree = "<group>"; };
F8FA94C0150F019100ED4EAD /* TweetTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TweetTableViewCell.m; sourceTree = "<group>"; };
F8FA94CC150F094D00ED4EAD /* profile-image-placeholder.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "profile-image-placeholder.png"; path = "Images/profile-image-placeholder.png"; sourceTree = SOURCE_ROOT; };
F8FA94CD150F094D00ED4EAD /* profile-image-placeholder@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "profile-image-placeholder@2x.png"; path = "Images/profile-image-placeholder@2x.png"; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -110,31 +107,11 @@
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
F8D25D0F1396A9C400CF3BD6 /* JSONKit */ = {
isa = PBXGroup;
children = (
F8D25D101396A9C400CF3BD6 /* JSONKit.h */,
F8D25D111396A9C400CF3BD6 /* JSONKit.m */,
);
name = JSONKit;
path = Vendor/JSONKit;
sourceTree = "<group>";
};
F8D25D121396A9C400CF3BD6 /* FormatterKit */ = {
isa = PBXGroup;
children = (
F8D25D131396A9C400CF3BD6 /* TTTLocationFormatter.h */,
F8D25D141396A9C400CF3BD6 /* TTTLocationFormatter.m */,
);
name = FormatterKit;
path = Vendor/TTT;
sourceTree = "<group>";
};
F8DA09C61396AB690057D0CC /* Controllers */ = {
isa = PBXGroup;
children = (
F8DA09C71396AB690057D0CC /* NearbySpotsViewController.h */,
F8DA09C81396AB690057D0CC /* NearbySpotsViewController.m */,
F8FA9498150EF9DA00ED4EAD /* PublicTimelineViewController.h */,
F8FA9499150EF9DA00ED4EAD /* PublicTimelineViewController.m */,
);
name = Controllers;
path = Classes/Controllers;
@ -143,8 +120,10 @@
F8DA09C91396AB690057D0CC /* Models */ = {
isa = PBXGroup;
children = (
F8DA09CA1396AB690057D0CC /* Spot.h */,
F8DA09CB1396AB690057D0CC /* Spot.m */,
F8FA9492150EF97E00ED4EAD /* Tweet.h */,
F8FA9493150EF97E00ED4EAD /* Tweet.m */,
F8FA9495150EF98800ED4EAD /* User.h */,
F8FA9496150EF98800ED4EAD /* User.m */,
);
name = Models;
path = Classes/Models;
@ -153,8 +132,8 @@
F8DA09CC1396AB690057D0CC /* Views */ = {
isa = PBXGroup;
children = (
F8DA09CD1396AB690057D0CC /* SpotTableViewCell.h */,
F8DA09CE1396AB690057D0CC /* SpotTableViewCell.m */,
F8FA94BF150F019100ED4EAD /* TweetTableViewCell.h */,
F8FA94C0150F019100ED4EAD /* TweetTableViewCell.m */,
);
name = Views;
path = Classes/Views;
@ -196,9 +175,9 @@
F8E4696A1395739D00DB05C8 /* Classes */ = {
isa = PBXGroup;
children = (
F8DA09C61396AB690057D0CC /* Controllers */,
F8DA09C91396AB690057D0CC /* Models */,
F8DA09CC1396AB690057D0CC /* Views */,
F8DA09C61396AB690057D0CC /* Controllers */,
F8E4696B1395739D00DB05C8 /* Supporting Files */,
);
name = Classes;
@ -220,46 +199,16 @@
F8E469931395743A00DB05C8 /* Vendor */ = {
isa = PBXGroup;
children = (
F8E469941395744600DB05C8 /* AFNetworking */,
F8D25D0F1396A9C400CF3BD6 /* JSONKit */,
F8D25D121396A9C400CF3BD6 /* FormatterKit */,
F8FA949B150EFEC100ED4EAD /* AFNetworking */,
);
name = Vendor;
sourceTree = "<group>";
};
F8E469941395744600DB05C8 /* AFNetworking */ = {
isa = PBXGroup;
children = (
F8D7DE781445F354000EF2F3 /* AFNetworking.h */,
F86E5527143A28F3002B438C /* AFURLConnectionOperation.h */,
F86E5528143A28F3002B438C /* AFURLConnectionOperation.m */,
F874B5D113E0AA6500B28E3E /* AFHTTPRequestOperation.h */,
F874B5C913E0AA6500B28E3E /* AFHTTPRequestOperation.m */,
F874B5D413E0AA6500B28E3E /* AFJSONRequestOperation.h */,
F874B5CC13E0AA6500B28E3E /* AFJSONRequestOperation.m */,
F8F4B17D143E07030064C9E6 /* AFXMLRequestOperation.h */,
F8F4B17E143E07030064C9E6 /* AFXMLRequestOperation.m */,
F8F4B16C143CD1410064C9E6 /* AFPropertyListRequestOperation.h */,
F8F4B16D143CD1410064C9E6 /* AFPropertyListRequestOperation.m */,
F8FBFA96142AA237001409DB /* AFHTTPClient.h */,
F8FBFA97142AA238001409DB /* AFHTTPClient.m */,
F874B5D313E0AA6500B28E3E /* AFImageRequestOperation.h */,
F874B5CB13E0AA6500B28E3E /* AFImageRequestOperation.m */,
F874B5D813E0AA6500B28E3E /* UIImageView+AFNetworking.h */,
F874B5D013E0AA6500B28E3E /* UIImageView+AFNetworking.m */,
F874B5D513E0AA6500B28E3E /* AFNetworkActivityIndicatorManager.h */,
F874B5CD13E0AA6500B28E3E /* AFNetworkActivityIndicatorManager.m */,
F8323C941455C03400190CCB /* AFJSONUtilities.h */,
F8689A9814CC9F5E0087F357 /* AFJSONUtilities.m */,
);
name = AFNetworking;
sourceTree = "<group>";
};
F8E469B71395759C00DB05C8 /* Networking Extensions */ = {
isa = PBXGroup;
children = (
F8D25D1B1396A9DE00CF3BD6 /* AFGowallaAPIClient.h */,
F8D25D1D1396A9DE00CF3BD6 /* AFGowallaAPIClient.m */,
F8FA948F150EF8C100ED4EAD /* AFTwitterAPIClient.h */,
F8FA9490150EF8C100ED4EAD /* AFTwitterAPIClient.m */,
);
name = "Networking Extensions";
sourceTree = "<group>";
@ -271,13 +220,42 @@
F8F6E8D71463424800AD016F /* Default@2x.png */,
F8F6E8D81463424800AD016F /* Icon.png */,
F8F6E8D91463424800AD016F /* Icon@2x.png */,
F8D25D171396A9D300CF3BD6 /* placeholder-stamp.png */,
F8D25D181396A9D300CF3BD6 /* placeholder-stamp@2x.png */,
F8FA94CC150F094D00ED4EAD /* profile-image-placeholder.png */,
F8FA94CD150F094D00ED4EAD /* profile-image-placeholder@2x.png */,
);
name = Images;
path = AFNetworkingExample/Images;
sourceTree = "<group>";
};
F8FA949B150EFEC100ED4EAD /* AFNetworking */ = {
isa = PBXGroup;
children = (
F8FA949C150EFEC100ED4EAD /* AFHTTPClient.h */,
F8FA949D150EFEC100ED4EAD /* AFHTTPClient.m */,
F8FA949E150EFEC100ED4EAD /* AFHTTPRequestOperation.h */,
F8FA949F150EFEC100ED4EAD /* AFHTTPRequestOperation.m */,
F8FA94A0150EFEC100ED4EAD /* AFImageRequestOperation.h */,
F8FA94A1150EFEC100ED4EAD /* AFImageRequestOperation.m */,
F8FA94A2150EFEC100ED4EAD /* AFJSONRequestOperation.h */,
F8FA94A3150EFEC100ED4EAD /* AFJSONRequestOperation.m */,
F8FA94A4150EFEC100ED4EAD /* AFJSONUtilities.h */,
F8FA94A5150EFEC100ED4EAD /* AFJSONUtilities.m */,
F8FA94A6150EFEC100ED4EAD /* AFNetworkActivityIndicatorManager.h */,
F8FA94A7150EFEC100ED4EAD /* AFNetworkActivityIndicatorManager.m */,
F8FA94A8150EFEC100ED4EAD /* AFNetworking.h */,
F8FA94A9150EFEC100ED4EAD /* AFPropertyListRequestOperation.h */,
F8FA94AA150EFEC100ED4EAD /* AFPropertyListRequestOperation.m */,
F8FA94AB150EFEC100ED4EAD /* AFURLConnectionOperation.h */,
F8FA94AC150EFEC100ED4EAD /* AFURLConnectionOperation.m */,
F8FA94AD150EFEC100ED4EAD /* AFXMLRequestOperation.h */,
F8FA94AE150EFEC100ED4EAD /* AFXMLRequestOperation.m */,
F8FA94AF150EFEC100ED4EAD /* UIImageView+AFNetworking.h */,
F8FA94B0150EFEC100ED4EAD /* UIImageView+AFNetworking.m */,
);
name = AFNetworking;
path = ../AFNetworking;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@ -329,12 +307,12 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
F8D25D191396A9D300CF3BD6 /* placeholder-stamp.png in Resources */,
F8D25D1A1396A9D300CF3BD6 /* placeholder-stamp@2x.png in Resources */,
F8F6E8DA1463424800AD016F /* Default.png in Resources */,
F8F6E8DB1463424800AD016F /* Default@2x.png in Resources */,
F8F6E8DC1463424800AD016F /* Icon.png in Resources */,
F8F6E8DD1463424800AD016F /* Icon@2x.png in Resources */,
F8FA94D0150F094D00ED4EAD /* profile-image-placeholder.png in Resources */,
F8FA94D1150F094D00ED4EAD /* profile-image-placeholder@2x.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -345,24 +323,23 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
F8DA09D21396ABED0057D0CC /* AFGowallaAPIClient.m in Sources */,
F8DA09D41396ABED0057D0CC /* NearbySpotsViewController.m in Sources */,
F8DA09D51396ABED0057D0CC /* Spot.m in Sources */,
F8DA09D61396ABED0057D0CC /* SpotTableViewCell.m in Sources */,
F8DA09E21396ABED0057D0CC /* TTTLocationFormatter.m in Sources */,
F8DA09E41396AC040057D0CC /* main.m in Sources */,
F8DA09E81396AC220057D0CC /* AppDelegate.m in Sources */,
F874B5D913E0AA6500B28E3E /* AFHTTPRequestOperation.m in Sources */,
F874B5DB13E0AA6500B28E3E /* AFImageRequestOperation.m in Sources */,
F874B5DC13E0AA6500B28E3E /* AFJSONRequestOperation.m in Sources */,
F874B5DD13E0AA6500B28E3E /* AFNetworkActivityIndicatorManager.m in Sources */,
F874B5E013E0AA6500B28E3E /* UIImageView+AFNetworking.m in Sources */,
F8FBFA98142AA239001409DB /* AFHTTPClient.m in Sources */,
F86E5529143A28F3002B438C /* AFURLConnectionOperation.m in Sources */,
F8F4B16E143CD1420064C9E6 /* AFPropertyListRequestOperation.m in Sources */,
F8F4B17F143E07030064C9E6 /* AFXMLRequestOperation.m in Sources */,
F8689A9914CC9F5E0087F357 /* AFJSONUtilities.m in Sources */,
3ACFD84015037DAB00FF5F0F /* JSONKit.m in Sources */,
F8FA9491150EF8C100ED4EAD /* AFTwitterAPIClient.m in Sources */,
F8FA9494150EF97E00ED4EAD /* Tweet.m in Sources */,
F8FA9497150EF98800ED4EAD /* User.m in Sources */,
F8FA949A150EF9DA00ED4EAD /* PublicTimelineViewController.m in Sources */,
F8FA94B1150EFEC100ED4EAD /* AFHTTPClient.m in Sources */,
F8FA94B2150EFEC100ED4EAD /* AFHTTPRequestOperation.m in Sources */,
F8FA94B3150EFEC100ED4EAD /* AFImageRequestOperation.m in Sources */,
F8FA94B4150EFEC100ED4EAD /* AFJSONRequestOperation.m in Sources */,
F8FA94B5150EFEC100ED4EAD /* AFJSONUtilities.m in Sources */,
F8FA94B6150EFEC100ED4EAD /* AFNetworkActivityIndicatorManager.m in Sources */,
F8FA94B7150EFEC100ED4EAD /* AFPropertyListRequestOperation.m in Sources */,
F8FA94B8150EFEC100ED4EAD /* AFURLConnectionOperation.m in Sources */,
F8FA94B9150EFEC100ED4EAD /* AFXMLRequestOperation.m in Sources */,
F8FA94BA150EFEC100ED4EAD /* UIImageView+AFNetworking.m in Sources */,
F8FA94C1150F019100ED4EAD /* TweetTableViewCell.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -405,10 +382,12 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ENABLE_OBJC_ARC = YES;
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = Prefix.pch;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_SHADOW = YES;
GCC_WARN_SIGN_COMPARE = YES;
GCC_WARN_UNUSED_PARAMETER = NO;
@ -422,9 +401,11 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ENABLE_OBJC_ARC = YES;
COPY_PHASE_STRIP = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = Prefix.pch;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_SHADOW = YES;
GCC_WARN_SIGN_COMPARE = YES;
GCC_WARN_UNUSED_PARAMETER = NO;

View file

@ -1,6 +1,6 @@
// AFNetworkingExampleAppDelegate.h
// AppDelegate.h
//
// Copyright (c) 2011 Gowalla (http://gowalla.com/)
// Copyright (c) 2012 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
@ -26,7 +26,7 @@
}
@property (nonatomic, retain) UIWindow *window;
@property (nonatomic, retain) UINavigationController *navigationController;
@property (nonatomic, strong) UIWindow *window;
@property (nonatomic, strong) UINavigationController *navigationController;
@end

View file

@ -1,6 +1,6 @@
// AFNetworkingExampleAppDelegate.m
// AppDelegate.m
//
// Copyright (c) 2011 Gowalla (http://gowalla.com/)
// Copyright (c) 2012 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
@ -21,7 +21,7 @@
// THE SOFTWARE.
#import "AppDelegate.h"
#import "NearbySpotsViewController.h"
#import "PublicTimelineViewController.h"
#import "AFNetworkActivityIndicatorManager.h"
@ -30,15 +30,16 @@
@synthesize navigationController = _navigationController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSURLCache *URLCache = [[[NSURLCache alloc] initWithMemoryCapacity:1024 * 1024 diskCapacity:1024 * 1024 * 5 diskPath:nil] autorelease];
NSURLCache *URLCache = [[NSURLCache alloc] initWithMemoryCapacity:1024 * 1024 diskCapacity:1024 * 1024 * 5 diskPath:nil];
[NSURLCache setSharedURLCache:URLCache];
[[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES];
UITableViewController *viewController = [[[NearbySpotsViewController alloc] init] autorelease];
self.navigationController = [[[UINavigationController alloc] initWithRootViewController:viewController] autorelease];
UITableViewController *viewController = [[PublicTimelineViewController alloc] initWithStyle:UITableViewStylePlain];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
self.navigationController.navigationBar.tintColor = [UIColor darkGrayColor];
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
@ -46,10 +47,5 @@
return YES;
}
- (void)dealloc {
[_window release];
[_navigationController release];
[super dealloc];
}
@end

View file

@ -1,6 +1,6 @@
// AFGowallaAPI.h
// AFTwitterAPIClient.h
//
// Copyright (c) 2011 Gowalla (http://gowalla.com/)
// Copyright (c) 2012 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
@ -23,9 +23,8 @@
#import <Foundation/Foundation.h>
#import "AFHTTPClient.h"
extern NSString * const kAFGowallaClientID;
extern NSString * const kAFGowallaBaseURLString;
@interface AFTwitterAPIClient : AFHTTPClient
+ (AFTwitterAPIClient *)sharedClient;
@interface AFGowallaAPIClient : AFHTTPClient
+ (AFGowallaAPIClient *)sharedClient;
@end

View file

@ -1,6 +1,6 @@
// AFGowallaAPI.m
// AFTwitterAPIClient.h
//
// Copyright (c) 2011 Gowalla (http://gowalla.com/)
// Copyright (c) 2012 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
@ -20,22 +20,19 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "AFGowallaAPIClient.h"
#import "AFTwitterAPIClient.h"
#import "AFJSONRequestOperation.h"
// Replace this with your own API Key, available at http://api.gowalla.com/api/keys/
NSString * const kAFGowallaClientID = @"e7ccb7d3d2414eb2af4663fc91eb2793";
static NSString * const kAFTwitterAPIBaseURLString = @"http://api.twitter.com/1/";
NSString * const kAFGowallaBaseURLString = @"https://api.gowalla.com/";
@implementation AFTwitterAPIClient
@implementation AFGowallaAPIClient
+ (AFGowallaAPIClient *)sharedClient {
static AFGowallaAPIClient *_sharedClient = nil;
static dispatch_once_t oncePredicate;
dispatch_once(&oncePredicate, ^{
_sharedClient = [[self alloc] initWithBaseURL:[NSURL URLWithString:kAFGowallaBaseURLString]];
+ (AFTwitterAPIClient *)sharedClient {
static AFTwitterAPIClient *_sharedClient = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_sharedClient = [[AFTwitterAPIClient alloc] initWithBaseURL:[NSURL URLWithString:kAFTwitterAPIBaseURLString]];
});
return _sharedClient;
@ -52,15 +49,6 @@ NSString * const kAFGowallaBaseURLString = @"https://api.gowalla.com/";
// Accept HTTP Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1
[self setDefaultHeader:@"Accept" value:@"application/json"];
// 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"];
// X-UDID HTTP Header
[self setDefaultHeader:@"X-UDID" value:[[UIDevice currentDevice] uniqueIdentifier]];
return self;
}

View file

@ -1,189 +0,0 @@
// 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 "NearbySpotsViewController.h"
#import "Spot.h"
#import "SpotTableViewCell.h"
#import "TTTLocationFormatter.h"
#import "UIImageView+AFNetworking.h"
@interface NearbySpotsViewController ()
@property (readwrite, nonatomic, retain) NSArray *nearbySpots;
@property (readwrite, nonatomic, retain) CLLocationManager *locationManager;
@property (readwrite, nonatomic, retain) UIActivityIndicatorView *activityIndicatorView;
- (void)loadSpotsForLocation:(CLLocation *)location;
- (void)refresh:(id)sender;
@end
@implementation NearbySpotsViewController
@synthesize nearbySpots = _spots;
@synthesize locationManager = _locationManager;
@synthesize activityIndicatorView = _activityIndicatorView;
- (id)init {
self = [super init];
if (!self) {
return nil;
}
self.nearbySpots = [NSArray array];
self.locationManager = [[[CLLocationManager alloc] init] autorelease];
self.locationManager.delegate = self;
self.locationManager.distanceFilter = 80.0;
return self;
}
- (void)dealloc {
[_spots release];
[_locationManager release];
[_activityIndicatorView release];
[super dealloc];
}
- (void)loadSpotsForLocation:(CLLocation *)location {
[self.activityIndicatorView startAnimating];
self.navigationItem.rightBarButtonItem.enabled = NO;
[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];
[self.activityIndicatorView stopAnimating];
self.navigationItem.rightBarButtonItem.enabled = YES;
}];
}
#pragma mark - UIViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.title = NSLocalizedString(@"AFNetworking", nil);
self.activityIndicatorView = [[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite] autorelease];
self.activityIndicatorView.hidesWhenStopped = YES;
self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:self.activityIndicatorView] autorelease];
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(refresh:)] autorelease];
self.navigationItem.rightBarButtonItem.enabled = NO;
[self.navigationController.navigationBar setTintColor:[UIColor darkGrayColor]];
self.tableView.rowHeight = 70.0f;
[self.locationManager startUpdatingLocation];
}
- (void)viewDidUnload {
[super viewDidUnload];
[self.locationManager stopUpdatingLocation];
}
#pragma mark - Actions
- (void)refresh:(id)sender {
self.nearbySpots = [NSArray array];
[self.tableView reloadData];
[[NSURLCache sharedURLCache] removeAllCachedResponses];
if (self.locationManager.location) {
[self loadSpotsForLocation:self.locationManager.location];
}
}
#pragma mark - CLLocationManagerDelegate
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
[self loadSpotsForLocation:newLocation];
}
#pragma mark - UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [self.nearbySpots count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
SpotTableViewCell *cell = (SpotTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[SpotTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}
Spot *spot = [self.nearbySpots objectAtIndex:indexPath.row];
static TTTLocationFormatter *_locationFormatter = nil;
if (!_locationFormatter) {
_locationFormatter = [[TTTLocationFormatter alloc] init];
if (![[[NSLocale currentLocale] objectForKey:NSLocaleUsesMetricSystem] boolValue]) {
[_locationFormatter setUnitSystem:TTTImperialSystem];
}
}
if (self.locationManager.location) {
cell.detailTextLabel.text = [_locationFormatter stringFromDistanceAndBearingFromLocation:self.locationManager.location toLocation:spot.location];
}
cell.spot = spot;
return cell;
}
#pragma mark - UITableViewDelegate
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
if ([self tableView:tableView numberOfRowsInSection:section] > 0) {
return NSLocalizedString(@"Nearby Spots", nil);
}
return nil;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
@end

View file

@ -1,6 +1,6 @@
// SpotTableViewCell.h
// PublicTimelineViewController.h
//
// Copyright (c) 2011 Gowalla (http://gowalla.com/)
// Copyright (c) 2012 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
@ -22,10 +22,6 @@
#import <UIKit/UIKit.h>
@class Spot;
@interface SpotTableViewCell : UITableViewCell
@property (nonatomic, retain) Spot *spot;
@interface PublicTimelineViewController : UITableViewController
@end

View file

@ -0,0 +1,120 @@
// PublicTimelineViewController.m
//
// Copyright (c) 2012 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 "PublicTimelineViewController.h"
#import "Tweet.h"
#import "TweetTableViewCell.h"
@interface PublicTimelineViewController ()
- (void)reload:(id)sender;
@end
@implementation PublicTimelineViewController {
@private
NSArray *_tweets;
__strong UIActivityIndicatorView *_activityIndicatorView;
}
- (void)reload:(id)sender {
[_activityIndicatorView startAnimating];
self.navigationItem.rightBarButtonItem.enabled = NO;
[Tweet publicTimelineTweetsWithBlock:^(NSArray *tweets) {
_tweets = tweets;
[self.tableView reloadData];
[_activityIndicatorView stopAnimating];
self.navigationItem.rightBarButtonItem.enabled = YES;
}];
}
#pragma mark - UIViewController
- (void)loadView {
[super loadView];
_activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
_activityIndicatorView.hidesWhenStopped = YES;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.title = NSLocalizedString(@"AFNetworking", nil);
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:_activityIndicatorView];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(reload:)];
self.tableView.rowHeight = 70.0f;
[self reload:nil];
}
- (void)viewDidUnload {
_activityIndicatorView = nil;
[super viewDidUnload];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
}
- (void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
}
#pragma mark - UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [_tweets count];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return [TweetTableViewCell heightForCellWithTweet:[_tweets objectAtIndex:indexPath.row]];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
TweetTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) {
cell = [[TweetTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
cell.tweet = [_tweets objectAtIndex:indexPath.row];
return cell;
}
@end

View file

@ -1,84 +0,0 @@
// 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;
}
- (void)dealloc {
[_name release];
[_imageURLString release];
[_latitude release];
[_longitude release];
[super dealloc];
}
- (CLLocation *)location {
return [[[CLLocation alloc] initWithLatitude:[self.latitude doubleValue] longitude:[self.longitude doubleValue]] autorelease];
}
+ (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"];
[mutableParameters setValue:[NSString stringWithFormat:@"%1.7f", location.coordinate.longitude] forKey:@"lng"];
}
[[AFGowallaAPIClient sharedClient] getPath:urlString parameters:mutableParameters success:^(__unused AFHTTPRequestOperation *operation, id JSON) {
NSMutableArray *mutableRecords = [NSMutableArray array];
for (NSDictionary *attributes in [JSON valueForKeyPath:@"spots"]) {
Spot *spot = [[[Spot alloc] initWithAttributes:attributes] autorelease];
[mutableRecords addObject:spot];
}
if (block) {
block([NSArray arrayWithArray:mutableRecords]);
}
} failure:^(__unused AFHTTPRequestOperation *operation, NSError *error) {
if (block) {
block([NSArray array]);
}
}];
}
@end

View file

@ -1,6 +1,6 @@
// Spot.h
// Tweet.h
//
// Copyright (c) 2011 Gowalla (http://gowalla.com/)
// Copyright (c) 2012 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
@ -21,23 +21,18 @@
// THE SOFTWARE.
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
@interface Spot : NSObject {
@private
NSString *_name;
NSString *_imageURLString;
NSNumber *_latitude;
NSNumber *_longitude;
}
@class User;
@property (nonatomic, retain) NSString *name;
@property (nonatomic, retain) NSString *imageURLString;
@property (nonatomic, retain) NSNumber *latitude;
@property (nonatomic, retain) NSNumber *longitude;
@property (readonly) CLLocation *location;
@interface Tweet : NSObject
@property (readonly) NSUInteger tweetID;
@property (readonly) NSString *text;
@property (readonly) User *user;
- (id)initWithAttributes:(NSDictionary *)attributes;
+ (void)spotsWithURLString:(NSString *)urlString near:(CLLocation *)location parameters:(NSDictionary *)parameters block:(void (^)(NSArray *records))block;
+ (void)publicTimelineTweetsWithBlock:(void (^)(NSArray *tweets))block;
@end

View file

@ -0,0 +1,71 @@
// Tweet.m
//
// Copyright (c) 2012 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 "Tweet.h"
#import "User.h"
#import "AFTwitterAPIClient.h"
@implementation Tweet {
@private
NSUInteger _tweetID;
__strong NSString *_text;
__strong User *_user;
}
@synthesize tweetID = _tweetID;
@synthesize text = _text;
@synthesize user = _user;
- (id)initWithAttributes:(NSDictionary *)attributes {
self = [super init];
if (!self) {
return nil;
}
_tweetID = [[attributes valueForKeyPath:@"id"] integerValue];
_text = [attributes valueForKeyPath:@"text"];
_user = [[User alloc] initWithAttributes:[attributes valueForKeyPath:@"user"]];
return self;
}
#pragma mark -
+ (void)publicTimelineTweetsWithBlock:(void (^)(NSArray *tweets))block {
[[AFTwitterAPIClient sharedClient] getPath:@"statuses/public_timeline.json" parameters:[NSDictionary dictionaryWithObject:@"false" forKey:@"include_entities"] success:^(AFHTTPRequestOperation *operation, id JSON) {
NSMutableArray *mutableTweets = [NSMutableArray arrayWithCapacity:[JSON count]];
for (NSDictionary *attributes in JSON) {
Tweet *tweet = [[Tweet alloc] initWithAttributes:attributes];
[mutableTweets addObject:tweet];
}
if (block) {
block([NSArray arrayWithArray:mutableTweets]);
}
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
}
@end

View file

@ -0,0 +1,33 @@
// User.h
//
// Copyright (c) 2012 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>
@interface User : NSObject
@property (readonly) NSUInteger userID;
@property (readonly) NSString *username;
@property (unsafe_unretained, readonly) NSURL *profileImageURL;
- (id)initWithAttributes:(NSDictionary *)attributes;
@end

View file

@ -0,0 +1,52 @@
// User.m
//
// Copyright (c) 2012 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 "User.h"
@implementation User {
@private
NSUInteger _userID;
__strong NSString *_username;
__strong NSString *_profileImageURLString;
}
@synthesize userID = _userID;
@synthesize username = _username;
- (id)initWithAttributes:(NSDictionary *)attributes {
self = [super init];
if (!self) {
return nil;
}
_userID = [[attributes valueForKeyPath:@"id"] integerValue];
_username = [attributes valueForKeyPath:@"screen_name"];
_profileImageURLString = [attributes valueForKeyPath:@"profile_image_url_https"];
return self;
}
- (NSURL *)profileImageURL {
return [NSURL URLWithString:_profileImageURLString];
}
@end

View file

@ -1,98 +0,0 @@
// SpotTableViewCell.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 "SpotTableViewCell.h"
#import "Spot.h"
#import "UIImageView+AFNetworking.h"
@implementation SpotTableViewCell
@synthesize spot = _spot;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (!self) {
return nil;
}
self.textLabel.textColor = [UIColor darkGrayColor];
self.textLabel.numberOfLines = 2;
self.textLabel.backgroundColor = self.backgroundColor;
self.detailTextLabel.textColor = [UIColor grayColor];
self.detailTextLabel.backgroundColor = self.backgroundColor;
self.imageView.backgroundColor = self.backgroundColor;
self.imageView.contentMode = UIViewContentModeScaleAspectFit;
self.selectionStyle = UITableViewCellSelectionStyleGray;
return self;
}
- (void)dealloc {
[_spot release];
[super dealloc];
}
- (void)setSpot:(Spot *)spot {
[self willChangeValueForKey:@"spot"];
[_spot autorelease];
_spot = [spot retain];
[self didChangeValueForKey:@"spot"];
[self.imageView setImageWithURL:[NSURL URLWithString:self.spot.imageURLString] placeholderImage:[UIImage imageNamed:@"placeholder-stamp.png"]];
self.textLabel.text = spot.name;
}
#pragma mark - UITableViewCell
- (void)prepareForReuse {
[super prepareForReuse];
[self.imageView cancelImageRequestOperation];
self.textLabel.text = nil;
self.detailTextLabel.text = nil;
}
#pragma mark - UIView
- (void)layoutSubviews {
[super layoutSubviews];
CGRect imageViewFrame = self.imageView.frame;
CGRect textLabelFrame = self.textLabel.frame;
CGRect detailTextLabelFrame = self.detailTextLabel.frame;
imageViewFrame.origin = CGPointMake(10.0f, 10.0f);
imageViewFrame.size = CGSizeMake(50.0f, 50.0f);
textLabelFrame.origin.x = imageViewFrame.size.width + 25.0f;
detailTextLabelFrame.origin.x = textLabelFrame.origin.x;
textLabelFrame.size.width = 240.0f;
detailTextLabelFrame.size.width = textLabelFrame.size.width;
self.textLabel.frame = textLabelFrame;
self.detailTextLabel.frame = detailTextLabelFrame;
self.imageView.frame = imageViewFrame;
}
@end

View file

@ -1,6 +1,6 @@
// NearbySpotsViewController.h
// TweetTableViewCell.h
//
// Copyright (c) 2011 Gowalla (http://gowalla.com/)
// Copyright (c) 2012 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
@ -21,12 +21,13 @@
// THE SOFTWARE.
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
@interface NearbySpotsViewController : UITableViewController <CLLocationManagerDelegate> {
NSArray *_nearbySpots;
CLLocationManager *_locationManager;
UIActivityIndicatorView *_activityIndicatorView;
}
@class Tweet;
@interface TweetTableViewCell : UITableViewCell
@property (nonatomic, strong) Tweet *tweet;
+ (CGFloat)heightForCellWithTweet:(Tweet *)tweet;
@end

View file

@ -0,0 +1,88 @@
// TweetTableViewCell.m
//
// Copyright (c) 2012 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 "TweetTableViewCell.h"
#import "Tweet.h"
#import "User.h"
#import "UIImageView+AFNetworking.h"
@implementation TweetTableViewCell {
@private
__strong Tweet *_tweet;
__strong UIImageView *_maskImageView;
}
@synthesize tweet = _tweet;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (!self) {
return nil;
}
self.textLabel.adjustsFontSizeToFitWidth = YES;
self.textLabel.textColor = [UIColor darkGrayColor];
self.detailTextLabel.font = [UIFont systemFontOfSize:12.0f];
self.detailTextLabel.numberOfLines = 0;
self.selectionStyle = UITableViewCellSelectionStyleGray;
_maskImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"profile-image-mask"]];
[self addSubview:_maskImageView];
return self;
}
- (void)setTweet:(Tweet *)tweet {
[self willChangeValueForKey:@"tweet"];
_tweet = tweet;
[self didChangeValueForKey:@"tweet"];
self.textLabel.text = _tweet.user.username;
self.detailTextLabel.text = _tweet.text;
[self.imageView setImageWithURL:_tweet.user.profileImageURL placeholderImage:[UIImage imageNamed:@"profile-image-placeholder"]];
[self setNeedsLayout];
}
+ (CGFloat)heightForCellWithTweet:(Tweet *)tweet {
CGSize sizeToFit = [tweet.text sizeWithFont:[UIFont systemFontOfSize:12.0f] constrainedToSize:CGSizeMake(220.0f, CGFLOAT_MAX) lineBreakMode:UILineBreakModeWordWrap];
return fmaxf(70.0f, sizeToFit.height + 45.0f);
}
#pragma mark - UIView
- (void)layoutSubviews {
[super layoutSubviews];
self.imageView.frame = CGRectMake(10.0f, 10.0f, 50.0f, 50.0f);
_maskImageView.frame = self.imageView.frame;
self.textLabel.frame = CGRectMake(70.0f, 10.0f, 240.0f, 20.0f);
CGRect detailTextLabelFrame = CGRectOffset(self.textLabel.frame, 0.0f, 25.0f);
detailTextLabelFrame.size.height = [[self class] heightForCellWithTweet:_tweet] - 45.0f;
self.detailTextLabel.frame = detailTextLabelFrame;
}
@end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View file

@ -1,251 +0,0 @@
//
// 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

File diff suppressed because it is too large Load diff

View file

@ -1,83 +0,0 @@
// 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

View file

@ -1,299 +0,0 @@
// 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

View file

@ -1,6 +1,6 @@
// main.m
//
// Copyright (c) 2011 Gowalla (http://gowalla.com/)
// Copyright (c) 2012 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
@ -23,8 +23,8 @@
#import <UIKit/UIKit.h>
int main(int argc, char *argv[]) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
@autoreleasepool {
int retVal = UIApplicationMain(argc, argv, @"UIApplication", @"AppDelegate");
[pool release];
return retVal;
}
}