Skip to content

Instantly share code, notes, and snippets.

View sukima's full-sized avatar

Devin Weaver sukima

View GitHub Profile
@sukima
sukima / gist:182384
Created September 7, 2009 14:28
Funny conversation from Omegle
<Stranger> can you love me?
<You> Top of the day to you. It is a pleasure to chat.
<Stranger> maybe
<Stranger> we will see
<You> How confusing
<Stranger> Entertain me
<You> What will you do in return?
<Stranger> love you
<You> Define love>
<You> How do I know that your "love" is what I want?
@sukima
sukima / dateSince.m
Created September 21, 2009 06:35
How to extract elapsed time from NSDate
// - since {{{
- (NSString *)since
{
// seed the test data. (in future passed in via a class instance variable)
NSString *dateStr = @"Mon May 05 17:26:30 +0000 2008";
// create our fommating object
NSDateFormatter *dateFormat = [[[NSDateFormatter alloc] init] autorelease];
[dateFormat setDateFormat:@"EEE MMM dd HH:mm:ss Z yyyy"];
@sukima
sukima / SomeObject.h
Created October 3, 2009 07:39
How to make a simple error reporter that is thread safe
#import <Foundation/Foundation.h>
@interface SomeObject : NSObject {
NSString *errorString;
NSArray *testArray;
}
@property (nonatomic, readonly) NSString *errorString;
@property (nonatomic, readonly) NSArray *testArray;
@sukima
sukima / UserListModal.m
Created October 10, 2009 01:40
How to best implement a data model
// Expose the internal data store. (Easiest but seems error prone)
@interface UserListModalExposeData : NSObject {
NSMutableArray *userList;
}
@property (nonatomic, retain) NSMutableArray *userList;
- (void) someAdditionalMethod;
@end
@sukima
sukima / test-plist-load.m
Created October 10, 2009 04:38
How to load a plist into an NSArray
/* Original code:
NSNumber *object = [[NSNumber alloc] init];
for(int i=0; i<[array count]; i++) {
NSLog(@"Value of number loaded %@", [array objectAtIndex:i]);
object = [array objectAtIndex:i];
}
*/
#import <Foundation/Foundation.h>
#import <Foundation/Foundation.h>
void checkIfFileExist(NSString *path)
{
NSFileManager *fileManager = [NSFileManager defaultManager];
if ( [fileManager fileExistsAtPath:path] )
NSLog(@"File exists!");
else
NSLog(@"File is missing!!!!");
#import <Foundation/Foundation.h>
@interface Person : NSObject {
NSString *screenName;
NSString *realName;
NSURL *imageURL;
}
@property (nonatomic, retain) NSString *screenName;
@property (nonatomic, retain) NSString *realName;
@sukima
sukima / ImageLoadingOp.h
Created November 4, 2009 20:05 — forked from quique123/ImageLoadingOp.h
Thread programming review
//
// ImageLoadingOp.h
// PersonList
//
// Created by Marcio Valenzuela on 10/20/09.
// Copyright 2009 Personal. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@sukima
sukima / MyView.h
Created November 18, 2009 11:07
How to make custom init methods for a UIView
// MyView.h
#import <UIKit/UIKit.h>
#import "Person.h"
@interface MyView : UIView {
Person *myPerson;
}
// Setup a property so we can programatically set the data for this view
// SimpleController.h
#import <Foundation/Foundation.h>
#import "Polygon.h"
@interface SimpleController : NSObject {
Polygon *myPolyObject;
}
- (void)testPassingVarToViewObject;
- (void)testAnotherWayPassingVarToViewObject;