Skip to content

Instantly share code, notes, and snippets.

@shto
shto / JBSpotifyLoginViewController.h
Created August 27, 2014 10:14
Spotify Login Helper
//
// JBSpotifyLoginViewController.h
// JukeBox
//
// Created by Andrei on 9/2/13.
// Copyright (c) 2013 andreipatru. All rights reserved.
//
#import "SPLoginViewController.h"
@shto
shto / NSManagedObject+Cloner.h
Last active April 20, 2018 04:53
NSManagedObject cloner files
#import <CoreData/CoreData.h>
@interface NSManagedObject (Cloner)
- (NSManagedObject *)clone;
- (NSManagedObject *)cloneInContext:(NSManagedObjectContext *)differentContext;
@end
@shto
shto / NSManagedObject+Cloner.h
Created March 14, 2014 17:21
Cloner .h file
#import <CoreData/CoreData.h>
@interface NSManagedObject (Cloner)
- (NSManagedObject *)clone;
- (NSManagedObject *)cloneInContext:(NSManagedObjectContext *)differentContext;
@end
@shto
shto / shoppingcart
Created March 14, 2014 15:12
Shopping Cart object
@interface ShoppingCart : NSObject
@property (nonatomic, strong) NSArray *items;
@property (nonatomic, strong) NSString *couponCode;
@end
@shto
shto / CopyPropertyMain
Last active August 29, 2015 13:57
main method for demonstrating copy awesomeness
#import "ShoppingCart.h"
int main(int argc, const char * argv[])
{
@autoreleasepool {
ShoppingCart *cart = [[ShoppingCart alloc] init];
cart.couponCode = @"1235AB1";
NSMutableArray *items = [[NSMutableArray alloc] init];
[items addObjectsFromArray:@[@"Book", @"Guitar", @"Sweater", @"Coffee Pot"]];
@shto
shto / passbyreference
Created March 14, 2014 15:02
Example of passing by reference in Objective-C
static void ChangeString(NSMutableString *theString) {
[theString insertString:@"xyzabc" atIndex:3];
NSLog(@"String inside ChangeString: %@", theString);
}
int main(int argc, const char * argv[])
{
@autoreleasepool {
NSMutableString *aString = [[NSMutableString alloc] initWithString:@"This is my string"];
NSLog(@"String before ChangeString: %@", aString);
@shto
shto / .gitignore
Created November 21, 2012 14:44 — forked from adamgit/.gitignore
.gitignore file for Xcode4 / OS X Source projects
#########################
# .gitignore file for Xcode4 / OS X Source projects
#
# NB: if you are storing "built" products, this WILL NOT WORK,
# and you should use a different .gitignore (or none at all)
# This file is for SOURCE projects, where there are many extra
# files that we want to exclude
#
# For updates, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects
#########################