Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
528 changes: 528 additions & 0 deletions PSCollectionViewDemo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions PSCollectionViewDemo/AppDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// AppDelegate.h
// PSCollectionViewDemo
//
// Created by Venus on 13-4-18.
// Copyright (c) 2013年 opomelo. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "MKNetworkKit.h"

@class ViewController;

@interface AppDelegate : UIResponder <UIApplicationDelegate> {
MKNetworkEngine *networkEngine;
}

+ (AppDelegate *)instance;

@property (strong, nonatomic) UIWindow *window;

@property (strong, nonatomic) ViewController *viewController;

@property (strong, nonatomic) MKNetworkEngine *networkEngine;

@end
67 changes: 67 additions & 0 deletions PSCollectionViewDemo/AppDelegate.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
//
// AppDelegate.m
// PSCollectionViewDemo
//
// Created by Venus on 13-4-18.
// Copyright (c) 2013年 opomelo. All rights reserved.
//

#import "AppDelegate.h"

#import "ViewController.h"

@implementation AppDelegate

@synthesize networkEngine;

+ (AppDelegate *)instance {
return (AppDelegate *)[[UIApplication sharedApplication] delegate];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler);

networkEngine = [[MKNetworkEngine alloc] initWithHostName:@"imgur.com" customHeaderFields:nil];

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application
{
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

void uncaughtExceptionHandler(NSException*exception){
NSLog(@"CRASH: %@", exception);
NSLog(@"Stack Trace: %@", [exception callStackSymbols]);
}

@end
32 changes: 32 additions & 0 deletions PSCollectionViewDemo/Categories/NSAlert+MKNetworkKitAdditions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// NSAlert+MKNetworkKitAdditions.h
// MKNetworkKitDemo
//
// Created by Mugunth Kumar (@mugunthkumar) on 11/11/11.
// Copyright (C) 2011-2020 by Steinlogic Consulting and Training Pte Ltd

// 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.

#if !TARGET_OS_IPHONE
#import <AppKit/AppKit.h>

@interface NSAlert (MKNetworkKitAdditions)
+(NSAlert*) showWithError:(NSError*) networkError;
@end
#endif
39 changes: 39 additions & 0 deletions PSCollectionViewDemo/Categories/NSAlert+MKNetworkKitAdditions.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// NSAlert+MKNetworkKitAdditions.m
// MKNetworkKitDemo
//
// Created by Mugunth Kumar (@mugunthkumar) on 11/11/11.
// Copyright (C) 2011-2020 by Steinlogic Consulting and Training Pte Ltd

// 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.
#if !TARGET_OS_IPHONE
#import "NSAlert+MKNetworkKitAdditions.h"

@implementation NSAlert (MKNetworkKitAdditions)

+(NSAlert*) showWithError:(NSError*) networkError {

DLog(@"%@", [networkError userInfo]);

NSAlert *alert = [NSAlert alertWithError:networkError];
[alert runModal];
return alert;
}
@end
#endif
42 changes: 42 additions & 0 deletions PSCollectionViewDemo/Categories/NSData+Base64.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//
// NSData+Base64.h
// base64
//
// Created by Matt Gallagher on 2009/06/03.
// Copyright 2009 Matt Gallagher. All rights reserved.
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software. Permission is granted to anyone to
// use this software for any purpose, including commercial applications, and to
// alter it and redistribute it freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source
// distribution.
//

#import <Foundation/Foundation.h>

void *NewBase64Decode(
const char *inputBuffer,
size_t length,
size_t *outputLength);

char *NewBase64Encode(
const void *inputBuffer,
size_t length,
bool separateLines,
size_t *outputLength);

@interface NSData (Base64)

+ (NSData *)dataFromBase64String:(NSString *)aString;
- (NSString *)base64EncodedString;

@end
Loading