Skip to content

Instantly share code, notes, and snippets.

View nwg's full-sized avatar

Nathaniel W Griswold nwg

  • Greater Milwaukee Area
View GitHub Profile
@nwg
nwg / classMock.m
Created March 7, 2012 07:04
Class mocking in objective c
@implementation OCMockObject (TestUtils)
+ (id)classMockForClass:(Class)class {
Class meta = object_getClass(class);
return [self mockForClass:meta];
}
@end
@nwg
nwg / declOrder.m
Created March 7, 2012 07:06
Objective c declaration order example
@interface MyController ()
- (void)doA ;
@end
@implementation MyController
- (void)doB{ doA(); }
- (void)doA{ }
@end
@implementation ClassMockTest
@synthesize mockAlert = mockAlert_;
- (BOOL)shouldRunOnMainThread { return YES; }
- (void)showAlert {
UIAlertView *alertView = [UIAlertView alloc];
alertView = [alertView initWithTitle:nil message:nil delegate:nil cancelButtonTitle:nil otherButtonTitles:nil];
[alertView show];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[Socialize storeUIErrorAlertsDisabled:YES];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(errorNotification:) name:SocializeUIControllerDidFailWithErrorNotification object:nil];
return YES;
}
- (void)errorNotification:(NSNotification*)notification {
NSError *error = [[notification userInfo] objectForKey:SocializeUIControllerErrorUserInfoKey];
NSLog(@"Error: %@", [error localizedDescription]);
#import <Socialize/Socialize.h>
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//set the FB App Id, you can find your FB app Id here: https://developers.facebook.com/apps
[Socialize storeFacebookAppId:@"YOUR FB APP ID"];
//your extra code goes here
}
//
// SampleEntityLoader.h
// SocializeSDK
//
// Created by Nathaniel Griswold on 1/11/12.
// Copyright (c) 2012 Socialize, Inc. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <Socialize/Socialize.h>
- (void)someMethod {
id<SocializeEntity> newEntity = [SocializeEntity entityWithKey:@"newEntity" name:@"New Entity"];
likeButton.entity = newEntity;
}
[Socialize setEntityLoaderBlock:^(UINavigationController *navigationController, id<SocializeEntity>entity) {
if ([[entity key] isEqualToString:@"key1"]) {
Loader1 *loader1 = [[[Loader1 alloc] initWithEntity:entity] autorelease];
[navigationController pushViewController:loader1 animated:YES];
} else if ([[entity key] isEqualToString:@"key2"]) {
Loader2 *loader2 = [[[Loader1 alloc] initWithEntity:entity] autorelease];
[navigationController pushViewController:loader2 animated:YES];
}
}];
#!/usr/bin/env python
import struct
from binascii import a2b_hex, b2a_hex
import socket
import ssl
import time
import sys
fmt = '!IH32s'
- (void)showProfile {
SZNavigationController *nav = [SocializeProfileViewController profileViewControllerInNavigationController];
[self presentModalViewController:nav animated:YES];
}