Skip to content

Instantly share code, notes, and snippets.

@jyaunches
jyaunches / gist:5145216
Created March 12, 2013 17:52
Examples of property attributes.
@property (nonatomic, strong) SomeOtherObject *containedObject;
@property (nonatomic, weak) SomeOtherObject *containerObject;
@propery (nonatomic) int value;
@property (nonatomic, readonly, strong) NSDate *dateCreated;
@jyaunches
jyaunches / gist:5145105
Last active December 14, 2015 20:39
Using accessors defined with property declaration.
SomeObject *myObj = [[SomeObject alloc] init];
[myObj setContainedObject:[[SomeOtherObject alloc] init]];
SomeOtherObject *otherObject = myObj.containedObject;
@jyaunches
jyaunches / SomeObject.h
Last active December 14, 2015 20:38
Header file showing property declaration.
@interface SomeObject : NSObject
@propery (nonatomic, strong) SomeOtherObject *containedObject;
@end
@jyaunches
jyaunches / SomeObject.h
Last active December 14, 2015 20:38
Instance variable with accessors definitions in header file.
@interface SomeObject : NSObject
{
SomeOtherObject *containedObject
}
- (void)setContainedObject(SomeOtherObject *)obj;
- (SomeOtherObject *)containedObject;
@end
@jyaunches
jyaunches / gist:5083231
Created March 4, 2013 15:55
Basic AF Networking request implementation
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:@"http://someurl/blah];
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id resultJSON) {
[self processResult:resultJSON];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
[self processFailuer:error];
}];
[operation start];
# See http://help.github.com/ignore-files/ for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile ~/.gitignore_global
# public/uploads/**/*
# Ignore bundler config
/.bundle
#import <Foundation/Foundation.h>
#import "NetworkActivityProtocol.h"
@interface SomeObjectFetcher : NSObject
@property (nonatomic,assign) id<NetworkActivityProtocol> networkActivityDelegate;
+ (SomeObjectFetcher *) sharedInstance;
- (void)startRequest;
@end
@interface SomeObjectFetcher ()
@property (nonatomic, strong) NSMutableData *responseData;
@end
@implementation SomeObjectFetcher
@synthesize networkActivityDelegate = _networkActivityDelegate;
+ (SomeObjectFetcher *) sharedInstance{
static AvailableFestivalFetcher *requestGenerator = nil;
NSURL *urlToRemoteServer = [NSURL URLWithString:[NSString stringWithFormat:@"%@/some_resource.json%@", YourURLToRemoteServer, additionalParams]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:urlToRemoteServer
cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData
timeoutInterval:15];
[request setHTTPMethod: @"GET"];
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
[connection start];
NSURL *apiURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@/some_resource.json%@", [[EnvironmentVars sharedInstance] yourAPIURL], path]];