mirror of
https://github.com/zhigang1992/FunctionalReactivePixels.git
synced 2026-01-12 17:22:42 +08:00
Basics of API use.
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
2826EB375D254DDD8DE6EAA8 /* libPods-FRP.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 772BE9E4C5824F1C8E5CDC45 /* libPods-FRP.a */; };
|
||||
5EBC599E180B247500B683A7 /* FRPCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EBC599D180B247500B683A7 /* FRPCell.m */; };
|
||||
5EBE2AF5180B07D0007B6BF3 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5EBE2AF4180B07D0007B6BF3 /* Foundation.framework */; };
|
||||
5EBE2AF7180B07D0007B6BF3 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5EBE2AF6180B07D0007B6BF3 /* CoreGraphics.framework */; };
|
||||
5EBE2AF9180B07D0007B6BF3 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5EBE2AF8180B07D0007B6BF3 /* UIKit.framework */; };
|
||||
@@ -21,6 +22,7 @@
|
||||
5EBE2B16180B07D0007B6BF3 /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5EBE2AFA180B07D0007B6BF3 /* CoreData.framework */; };
|
||||
5EBE2B1E180B07D0007B6BF3 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 5EBE2B1C180B07D0007B6BF3 /* InfoPlist.strings */; };
|
||||
5EBE2B20180B07D0007B6BF3 /* FRPTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EBE2B1F180B07D0007B6BF3 /* FRPTests.m */; };
|
||||
5EBE2B2B180B0AF1007B6BF3 /* FRPGalleryViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EBE2B2A180B0AF1007B6BF3 /* FRPGalleryViewController.m */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
@@ -34,6 +36,8 @@
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
5EBC599C180B247500B683A7 /* FRPCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FRPCell.h; sourceTree = "<group>"; };
|
||||
5EBC599D180B247500B683A7 /* FRPCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FRPCell.m; sourceTree = "<group>"; };
|
||||
5EBE2AF1180B07D0007B6BF3 /* FRP.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FRP.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
5EBE2AF4180B07D0007B6BF3 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
|
||||
5EBE2AF6180B07D0007B6BF3 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
|
||||
@@ -51,6 +55,8 @@
|
||||
5EBE2B1B180B07D0007B6BF3 /* FRPTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "FRPTests-Info.plist"; sourceTree = "<group>"; };
|
||||
5EBE2B1D180B07D0007B6BF3 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
||||
5EBE2B1F180B07D0007B6BF3 /* FRPTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FRPTests.m; sourceTree = "<group>"; };
|
||||
5EBE2B29180B0AF1007B6BF3 /* FRPGalleryViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FRPGalleryViewController.h; sourceTree = "<group>"; };
|
||||
5EBE2B2A180B0AF1007B6BF3 /* FRPGalleryViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FRPGalleryViewController.m; sourceTree = "<group>"; };
|
||||
772BE9E4C5824F1C8E5CDC45 /* libPods-FRP.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-FRP.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
CF6C5FA73F5F4703A3C7C4C0 /* Pods-FRP.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-FRP.xcconfig"; path = "Pods/Pods-FRP.xcconfig"; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
@@ -119,6 +125,10 @@
|
||||
children = (
|
||||
5EBE2B05180B07D0007B6BF3 /* FRPAppDelegate.h */,
|
||||
5EBE2B06180B07D0007B6BF3 /* FRPAppDelegate.m */,
|
||||
5EBE2B29180B0AF1007B6BF3 /* FRPGalleryViewController.h */,
|
||||
5EBE2B2A180B0AF1007B6BF3 /* FRPGalleryViewController.m */,
|
||||
5EBC599C180B247500B683A7 /* FRPCell.h */,
|
||||
5EBC599D180B247500B683A7 /* FRPCell.m */,
|
||||
5EBE2B0B180B07D0007B6BF3 /* Images.xcassets */,
|
||||
5EBE2AFD180B07D0007B6BF3 /* Supporting Files */,
|
||||
);
|
||||
@@ -285,7 +295,9 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
5EBC599E180B247500B683A7 /* FRPCell.m in Sources */,
|
||||
5EBE2B03180B07D0007B6BF3 /* main.m in Sources */,
|
||||
5EBE2B2B180B0AF1007B6BF3 /* FRPGalleryViewController.m in Sources */,
|
||||
5EBE2B07180B07D0007B6BF3 /* FRPAppDelegate.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
// Pods
|
||||
#import <ReactiveCocoa/ReactiveCocoa.h>
|
||||
#import <500px-iOS-api/PXAPI.h>
|
||||
#import <libextobjc/EXTScope.h>
|
||||
|
||||
// App Delegate
|
||||
#import "FRPAppDelegate.h"
|
||||
|
||||
@@ -12,4 +12,6 @@
|
||||
|
||||
@property (strong, nonatomic) UIWindow *window;
|
||||
|
||||
@property (nonatomic, readonly) PXAPIHelper *apiHelper;
|
||||
|
||||
@end
|
||||
|
||||
@@ -8,13 +8,23 @@
|
||||
|
||||
#import "FRPAppDelegate.h"
|
||||
|
||||
@implementation FRPAppDelegate
|
||||
#import "FRPGalleryViewController.h"
|
||||
|
||||
@interface FRPAppDelegate ()
|
||||
|
||||
@property (nonatomic, strong) PXAPIHelper *apiHelper;
|
||||
|
||||
@end
|
||||
|
||||
@implementation FRPAppDelegate
|
||||
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
||||
{
|
||||
self.apiHelper = [[PXAPIHelper alloc] initWithHost:nil consumerKey:@"DC2To2BS0ic1ChKDK15d44M42YHf9gbUJgdFoF0m" consumerSecret:@"i8WL4chWoZ4kw9fh3jzHK7XzTer1y5tUNvsTFNnB"];
|
||||
|
||||
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
||||
// Override point for customization after application launch.
|
||||
self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:[[FRPGalleryViewController alloc] init]];
|
||||
|
||||
self.window.backgroundColor = [UIColor whiteColor];
|
||||
[self.window makeKeyAndVisible];
|
||||
return YES;
|
||||
|
||||
13
FRP/FRPCell.h
Normal file
13
FRP/FRPCell.h
Normal file
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// FRPCell.h
|
||||
// FRP
|
||||
//
|
||||
// Created by Ash Furrow on 10/13/2013.
|
||||
// Copyright (c) 2013 Ash Furrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface FRPCell : UICollectionViewCell
|
||||
|
||||
@end
|
||||
31
FRP/FRPCell.m
Normal file
31
FRP/FRPCell.m
Normal file
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// FRPCell.m
|
||||
// FRP
|
||||
//
|
||||
// Created by Ash Furrow on 10/13/2013.
|
||||
// Copyright (c) 2013 Ash Furrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import "FRPCell.h"
|
||||
|
||||
@implementation FRPCell
|
||||
|
||||
- (id)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
// Initialization code
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/*
|
||||
// Only override drawRect: if you perform custom drawing.
|
||||
// An empty implementation adversely affects performance during animation.
|
||||
- (void)drawRect:(CGRect)rect
|
||||
{
|
||||
// Drawing code
|
||||
}
|
||||
*/
|
||||
|
||||
@end
|
||||
15
FRP/FRPGalleryViewController.h
Normal file
15
FRP/FRPGalleryViewController.h
Normal file
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// FRPGalleryViewController.h
|
||||
// FRP
|
||||
//
|
||||
// Created by Ash Furrow on 10/13/2013.
|
||||
// Copyright (c) 2013 Ash Furrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface FRPGalleryViewController : UICollectionViewController
|
||||
|
||||
-(id)init;
|
||||
|
||||
@end
|
||||
89
FRP/FRPGalleryViewController.m
Normal file
89
FRP/FRPGalleryViewController.m
Normal file
@@ -0,0 +1,89 @@
|
||||
//
|
||||
// FRPGalleryViewController.m
|
||||
// FRP
|
||||
//
|
||||
// Created by Ash Furrow on 10/13/2013.
|
||||
// Copyright (c) 2013 Ash Furrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import "FRPGalleryViewController.h"
|
||||
#import "FRPCell.h"
|
||||
|
||||
static NSString *CellIdentifier = @"Cell";
|
||||
|
||||
@interface FRPGalleryViewController ()
|
||||
|
||||
@property (nonatomic, strong) NSArray *photosArray;
|
||||
|
||||
@end
|
||||
|
||||
@implementation FRPGalleryViewController
|
||||
|
||||
- (id)init
|
||||
{
|
||||
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
|
||||
|
||||
self = [super initWithCollectionViewLayout:flowLayout];
|
||||
if (!self) return nil;
|
||||
|
||||
flowLayout.itemSize = CGSizeMake(145, 145);
|
||||
flowLayout.minimumInteritemSpacing = 10;
|
||||
flowLayout.minimumLineSpacing = 10;
|
||||
flowLayout.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
// Configure self
|
||||
self.title = @"Popular on 500px";
|
||||
|
||||
// Configure view
|
||||
[self.collectionView registerClass:[FRPCell class] forCellWithReuseIdentifier:CellIdentifier];
|
||||
|
||||
// Reactive Stuff
|
||||
@weakify(self);
|
||||
[RACObserve(self, photosArray) subscribeNext:^(id x) {
|
||||
@strongify(self);
|
||||
|
||||
[self.collectionView reloadData];
|
||||
}];
|
||||
|
||||
[self loadPopularPhotos];
|
||||
}
|
||||
|
||||
#pragma mark - Private Methods
|
||||
|
||||
-(void)loadPopularPhotos {
|
||||
NSURLRequest *request = [AppDelegate.apiHelper urlRequestForPhotoFeature:PXAPIHelperPhotoFeaturePopular resultsPerPage:100 page:1 photoSizes:PXPhotoModelSizeThumbnail sortOrder:PXAPIHelperSortOrderRating except:PXPhotoModelCategoryNude];
|
||||
|
||||
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
|
||||
if (data) {
|
||||
id results = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
|
||||
|
||||
self.photosArray = results[@"photos"];
|
||||
}
|
||||
else {
|
||||
NSLog(@"Couldn't fetch from 500px: %@", connectionError);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - UICollectionViewDataSource Methods
|
||||
|
||||
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
|
||||
return self.photosArray.count;
|
||||
}
|
||||
|
||||
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
|
||||
FRPCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
|
||||
|
||||
cell.backgroundColor = [UIColor purpleColor];
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
@end
|
||||
1
Podfile
1
Podfile
@@ -3,6 +3,7 @@ platform :ios, "7.0"
|
||||
target "FRP" do
|
||||
|
||||
pod 'ReactiveCocoa', '2.1'
|
||||
pod 'libextobjc', '0.3'
|
||||
pod '500px-iOS-api', '1.0.4'
|
||||
|
||||
end
|
||||
|
||||
88
Podfile.lock
88
Podfile.lock
@@ -1,5 +1,90 @@
|
||||
PODS:
|
||||
- 500px-iOS-api (1.0.4)
|
||||
- libextobjc (0.3):
|
||||
- libextobjc/EXTADT
|
||||
- libextobjc/EXTAnnotation
|
||||
- libextobjc/EXTAspect
|
||||
- libextobjc/EXTBlockMethod
|
||||
- libextobjc/EXTBlockTarget
|
||||
- libextobjc/EXTConcreteProtocol
|
||||
- libextobjc/EXTDispatchObject
|
||||
- libextobjc/EXTFinalMethod
|
||||
- libextobjc/EXTKeyPathCoding
|
||||
- libextobjc/EXTMaybe
|
||||
- libextobjc/EXTMixin
|
||||
- libextobjc/EXTMultimethod
|
||||
- libextobjc/EXTMultiObject
|
||||
- libextobjc/EXTNil
|
||||
- libextobjc/EXTPassthrough
|
||||
- libextobjc/EXTPrivateMethod
|
||||
- libextobjc/EXTProtocolCategory
|
||||
- libextobjc/EXTSafeCategory
|
||||
- libextobjc/EXTScope
|
||||
- libextobjc/EXTSelectorChecking
|
||||
- libextobjc/EXTSwizzle
|
||||
- libextobjc/EXTSynthesize
|
||||
- libextobjc/EXTTuple
|
||||
- libextobjc/EXTVarargs
|
||||
- libextobjc/NSInvocation+EXT
|
||||
- libextobjc/NSMethodSignature+EXT
|
||||
- libextobjc/RuntimeExtensions
|
||||
- libextobjc/UmbrellaHeader
|
||||
- libextobjc/EXTADT (0.3):
|
||||
- libextobjc/RuntimeExtensions
|
||||
- libextobjc/EXTAnnotation (0.3):
|
||||
- libextobjc/RuntimeExtensions
|
||||
- libextobjc/EXTAspect (0.3):
|
||||
- libextobjc/RuntimeExtensions
|
||||
- libffi
|
||||
- libextobjc/EXTBlockMethod (0.3):
|
||||
- libextobjc/RuntimeExtensions
|
||||
- libextobjc/EXTBlockTarget (0.3):
|
||||
- libextobjc/RuntimeExtensions
|
||||
- libextobjc/EXTConcreteProtocol (0.3):
|
||||
- libextobjc/RuntimeExtensions
|
||||
- libextobjc/EXTDispatchObject (0.3):
|
||||
- libextobjc/RuntimeExtensions
|
||||
- libextobjc/EXTFinalMethod (0.3):
|
||||
- libextobjc/RuntimeExtensions
|
||||
- libextobjc/EXTKeyPathCoding (0.3):
|
||||
- libextobjc/RuntimeExtensions
|
||||
- libextobjc/EXTMaybe (0.3):
|
||||
- libextobjc/RuntimeExtensions
|
||||
- libextobjc/EXTMixin (0.3):
|
||||
- libextobjc/RuntimeExtensions
|
||||
- libextobjc/EXTMultimethod (0.3):
|
||||
- libextobjc/RuntimeExtensions
|
||||
- libextobjc/EXTMultiObject (0.3):
|
||||
- libextobjc/RuntimeExtensions
|
||||
- libextobjc/EXTNil (0.3):
|
||||
- libextobjc/RuntimeExtensions
|
||||
- libextobjc/EXTPassthrough (0.3):
|
||||
- libextobjc/RuntimeExtensions
|
||||
- libextobjc/EXTPrivateMethod (0.3):
|
||||
- libextobjc/RuntimeExtensions
|
||||
- libextobjc/EXTProtocolCategory (0.3):
|
||||
- libextobjc/RuntimeExtensions
|
||||
- libextobjc/EXTSafeCategory (0.3):
|
||||
- libextobjc/RuntimeExtensions
|
||||
- libextobjc/EXTScope (0.3):
|
||||
- libextobjc/RuntimeExtensions
|
||||
- libextobjc/EXTSelectorChecking (0.3):
|
||||
- libextobjc/RuntimeExtensions
|
||||
- libextobjc/EXTSwizzle (0.3):
|
||||
- libextobjc/RuntimeExtensions
|
||||
- libextobjc/EXTSynthesize (0.3):
|
||||
- libextobjc/RuntimeExtensions
|
||||
- libextobjc/EXTTuple (0.3):
|
||||
- libextobjc/RuntimeExtensions
|
||||
- libextobjc/EXTVarargs (0.3):
|
||||
- libextobjc/RuntimeExtensions
|
||||
- libextobjc/NSInvocation+EXT (0.3):
|
||||
- libextobjc/RuntimeExtensions
|
||||
- libextobjc/NSMethodSignature+EXT (0.3):
|
||||
- libextobjc/RuntimeExtensions
|
||||
- libextobjc/RuntimeExtensions (0.3)
|
||||
- libextobjc/UmbrellaHeader (0.3)
|
||||
- libffi (3.0.13)
|
||||
- ReactiveCocoa (2.1):
|
||||
- ReactiveCocoa/Core
|
||||
- ReactiveCocoa/no-arc
|
||||
@@ -9,10 +94,13 @@ PODS:
|
||||
|
||||
DEPENDENCIES:
|
||||
- 500px-iOS-api (= 1.0.4)
|
||||
- libextobjc (= 0.3)
|
||||
- ReactiveCocoa (= 2.1)
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
500px-iOS-api: fde71ddd4a05f06b94b8ec7c29bbcd2e589b7e70
|
||||
libextobjc: 820a79dbbbc498611e04fffd07d2d52a5588e7ac
|
||||
libffi: 64ef39353e747bb2b25e1026afd96a157bf9231c
|
||||
ReactiveCocoa: b686fa735c28c2dc7311fbd2f0895b4d4ae07360
|
||||
|
||||
COCOAPODS: 0.25.0
|
||||
|
||||
Reference in New Issue
Block a user