From: Fraser S. <fra...@us...> - 2004-10-06 08:21:43
|
Update of /cvsroot/ljkit/LJKit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19475 Modified Files: LJAccount.h LJAccount.m LJAccount_EditFriends.m LJKit.h Log Message: Updates for better KVO compliance Index: LJAccount_EditFriends.m =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJAccount_EditFriends.m,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** LJAccount_EditFriends.m 5 Oct 2004 20:21:49 -0000 1.3 --- LJAccount_EditFriends.m 6 Oct 2004 08:21:31 -0000 1.4 *************** *** 43,48 **** --- 43,50 ---- // Update the static ordered array cache if(_orderedGroupArrayCache) { + [self willChangeValueForKey: @"groupArray"]; [_orderedGroupArrayCache release]; _orderedGroupArrayCache = [[[_groupSet allObjects] sortedArrayUsingSelector: @selector(compare:)] retain]; + [self didChangeValueForKey: @"groupArray"]; } } *************** *** 104,109 **** --- 106,113 ---- if(_orderedFriendArrayCache) { // The underlying set changed, so update the cache + [self willChangeValueForKey: @"friendArray"]; [_orderedFriendArrayCache release]; _orderedFriendArrayCache = [[[_friendSet allObjects] sortedArrayUsingSelector:@selector(compare:)] retain]; + [self didChangeValueForKey: @"friendArray"]; } *************** *** 180,184 **** _orderedGroupArrayCache = [[[_groupSet allObjects] sortedArrayUsingSelector: @selector(compare:)] retain]; ! return [[_orderedGroupArrayCache copy] autorelease]; //[[_groupSet allObjects] sortedArrayUsingSelector:@selector(compare:)]; } --- 184,188 ---- _orderedGroupArrayCache = [[[_groupSet allObjects] sortedArrayUsingSelector: @selector(compare:)] retain]; ! return [[_orderedGroupArrayCache copy] autorelease]; } *************** *** 303,308 **** --- 307,314 ---- if(_orderedFriendArrayCache) { // The underlying set changed, so change the cache + [self willChangeValueForKey: @"friendArray"]; [_orderedFriendArrayCache release]; _orderedFriendArrayCache = [[[_friendSet allObjects] sortedArrayUsingSelector:@selector(compare:)] retain]; + [self didChangeValueForKey: @"friendArray"]; } *************** *** 320,325 **** --- 326,333 ---- if(_orderedFriendArrayCache) { + [self willChangeValueForKey: @"friendArray"]; [_orderedFriendArrayCache release]; _orderedFriendArrayCache = [[[_friendSet allObjects] sortedArrayUsingSelector:@selector(compare:)] retain]; + [self didChangeValueForKey: @"friendArray"]; } } *************** *** 343,348 **** --- 351,358 ---- // Update the static ordered array cache if(_orderedGroupArrayCache) { + [self willChangeValueForKey: @"groupArray"]; [_orderedGroupArrayCache release]; _orderedGroupArrayCache = [[[_groupSet allObjects] sortedArrayUsingSelector: @selector(compare:)] retain]; + [self didChangeValueForKey: @"groupArray"]; } *************** *** 372,377 **** --- 382,389 ---- // Update the static ordered array cache if(_orderedGroupArrayCache) { + [self willChangeValueForKey: @"groupArray"]; [_orderedGroupArrayCache release]; _orderedGroupArrayCache = [[[_groupSet allObjects] sortedArrayUsingSelector: @selector(compare:)] retain]; + [self didChangeValueForKey: @"groupArray"]; } } Index: LJAccount.h =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJAccount.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** LJAccount.h 5 Oct 2004 20:21:49 -0000 1.6 --- LJAccount.h 6 Oct 2004 08:21:31 -0000 1.7 *************** *** 421,424 **** --- 421,436 ---- /*! + @method userPictureKeywords + @abstract Returns an NSArray of account picture keywords in NSStrings. + @discussion + If you provided the LJGetPicturesLoginFlag to the loginWithPassword:flags: + method, this method will return an NSArray of NSStrings. Otherwise, returns nil. + + This property is preserved during archiving. + */ + - (NSArray *)userPictureKeywords; + + + /*! @method userPicturesDictionary @abstract Returns a dictionary of account picture keywords and URLs. Index: LJAccount.m =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJAccount.m,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** LJAccount.m 28 Jul 2004 05:38:20 -0000 1.8 --- LJAccount.m 6 Oct 2004 08:21:31 -0000 1.9 *************** *** 60,63 **** --- 60,68 ---- @end + @interface LJAccount (PrivateImpl) + - (void)setJournalArray:(NSArray *)aJournalArray; + - (void) setUserPicturesDictionary: (NSDictionary *)aDict; + @end + @implementation LJAccount *************** *** 106,109 **** --- 111,117 ---- gClientVersion = [[NSString alloc] initWithFormat:@"MacOSX-%@/%@", name, version]; NSLog(@"LJKit Client Version: %@", gClientVersion); + + // Set up KVO for the dependent key "userPictureKeywords" which depends on userPicturesDictionary + [self setKeys: [NSArray arrayWithObject: @"userPicturesDictionary"] triggerChangeNotificationsForDependentKey: @"userPictureKeywords"]; } } *************** *** 202,205 **** --- 210,214 ---- } } + return self; } *************** *** 462,467 **** url = (key != nil ? [NSURL URLWithString:key] : nil); SafeSetObject(&_defaultUserPictureURL, url); ! [_userPicturesDictionary release]; ! _userPicturesDictionary = [userPics copy]; [userPics release]; } --- 471,477 ---- url = (key != nil ? [NSURL URLWithString:key] : nil); SafeSetObject(&_defaultUserPictureURL, url); ! ! // [FS] Added use of accessor here ! [self setUserPicturesDictionary: [userPics copy]]; [userPics release]; } *************** *** 520,525 **** } journals = [LJJournal _journalArrayFromLoginReply:reply account:self]; ! [_journalArray release]; ! _journalArray = [journals retain]; if (loginFlags & LJGetMoodsLoginFlag) { [_moods updateMoodsWithLoginReply:reply]; --- 530,535 ---- } journals = [LJJournal _journalArrayFromLoginReply:reply account:self]; ! // [FS] Changed this from direct ivar access for KVO reasons ! [self setJournalArray: journals]; if (loginFlags & LJGetMoodsLoginFlag) { [_moods updateMoodsWithLoginReply:reply]; *************** *** 570,573 **** --- 580,588 ---- } + - (NSArray *)userPictureKeywords { + // [FS] This is potenitally a performance hot spot, but let's be guided by profiling. + return [[_userPicturesDictionary allKeys] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)]; + } + - (NSDictionary *)userPicturesDictionary { *************** *** 575,578 **** --- 590,601 ---- } + // [FS] For key value observing + - (void) setUserPicturesDictionary: (NSDictionary *)aDict { + NSLog(@"Setting user pictures dictionary"); + [aDict retain]; + [_userPicturesDictionary release]; + _userPicturesDictionary = aDict; + } + - (NSURL *)defaultUserPictureURL { *************** *** 630,633 **** --- 653,667 ---- } + // =========================================================== + // - setJournalArray: + // =========================================================== + - (void)setJournalArray:(NSArray *)aJournalArray { + if (_journalArray != aJournalArray) { + [aJournalArray retain]; + [_journalArray release]; + _journalArray = aJournalArray; + } + } + - (LJJournal *)defaultJournal { Index: LJKit.h =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJKit.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** LJKit.h 14 May 2003 05:39:47 -0000 1.1.1.1 --- LJKit.h 6 Oct 2004 08:21:31 -0000 1.2 *************** *** 91,92 **** --- 91,93 ---- #import <LJKit/LJGroup.h> #import <LJKit/LJHttpURLs.h> + #import <LJKit/LJUserEntity.h> \ No newline at end of file |