PageRenderTime 17ms CodeModel.GetById 7ms app.highlight 9ms RepoModel.GetById 0ms app.codeStats 0ms

/FSKit/Source/Common/FSKContributorRepository.m

http://fskit.googlecode.com/
Objective C | 111 lines | 72 code | 16 blank | 23 comment | 6 complexity | 0cc83e1d6fb8aebaf59b25e4506819ca MD5 | raw file
Possible License(s): BSD-3-Clause
  1//
  2//  FSKUserRepository.m
  3//  FSKit
  4//
  5//  Created by Logan Allred on 8/24/08.
  6//  Copyright 2008 RedBugz Software. All rights reserved.
  7//
  8
  9#import "FSKContributorRepository.h"
 10#import "FSKContributorReadRequest.h"
 11
 12@implementation FSKContributorRepository
 13static FSKContributorRepository *sharedInstance = nil;
 14
 15+ (FSKContributorRepository*)instanceWithConnection:(FSKConnection *)aConnection
 16{
 17    @synchronized(self) {
 18        if (sharedInstance == nil) {
 19            [[self alloc] initWithConnection:aConnection]; // assignment not done here
 20        }
 21    }
 22    return sharedInstance;
 23}
 24
 25+ (id)allocWithZone:(NSZone *)zone
 26{
 27    @synchronized(self) {
 28        if (sharedInstance == nil) {
 29            sharedInstance = [super allocWithZone:zone];
 30            return sharedInstance;  // assignment and return on first allocation
 31        }
 32    }
 33    return nil; //on subsequent allocation attempts return nil
 34}
 35
 36- (id)copyWithZone:(NSZone *)zone
 37{
 38    return self;
 39}
 40
 41- (id)retain
 42{
 43    return self;
 44}
 45
 46- (NSUInteger)retainCount
 47{
 48    return UINT_MAX;  //denotes an object that cannot be released
 49}
 50
 51- (void)release
 52{
 53    //do nothing
 54}
 55
 56- (id)autorelease
 57{
 58    return self;
 59}
 60
 61- (id)initWithConnection:(FSKConnection *)aConnection
 62{
 63    if ((self = [super init]) != nil) 
 64	{ 		
 65		repository = [[[FSKRepository alloc] initWithIdentifier:[self className]] retain];
 66		connection = [aConnection retain];
 67	}
 68	
 69	return self;
 70}
 71
 72- (void)dealloc
 73{
 74	[connection release];
 75	[repository release];
 76	[super dealloc];
 77}
 78
 79
 80- (FSKContributor *)contributorForId:(NSString *)contributorId;
 81{
 82//	FSKUser *cachedUser = [cache objectForKey:userId];
 83//	if (!cachedUser)
 84//	{
 85//		// fetch and put in cache
 86//		cachedUser = [[FSKUser alloc] init];
 87//		[cachedUser setValue:userId forKey:@"userId"];
 88//		
 89//		[FSKUserReadRequest fetchUserDataWithIds:[NSSet setWithObject:userId] parameters:nil connection:connection delegate:self selector:@selector(request:didReturnResponse:)]; 
 90//	}
 91//	
 92//	return cachedUser;
 93	return nil;
 94}
 95
 96- (void)request:(FSKRequest *)request 
 97didReturnResponse:(FSKResponse *)response
 98{
 99	NSLog(@"%s %@", __PRETTY_FUNCTION__, response);
100//	FSKUserResponse *userResponse = (FSKUserResponse *)response;
101//	FSKUser *responseUser = [[userResponse userList] lastObject];
102//	FSKUser *cachedUser = [cache objectForKey:[responseUser userId]];
103//	[cache setObject:responseUser forKey:[[userResponse valueForKey:@"requestedIds"] lastObject]];
104}
105
106- (void)request:(FSKRequest *)request 
107didFailWithError:(FSKError *)error
108{
109	NSLog(@"%s %@", __PRETTY_FUNCTION__, error);
110}
111@end