Navigation Menu

Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Commit

Permalink
[TTCatalog] made the MockAdressBook behave like a remote model
Browse files Browse the repository at this point in the history
- load data in load:more
- release old data before searching
  • Loading branch information
diederich committed Feb 13, 2011
1 parent fd16b96 commit 668598c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions samples/TTCatalog/Classes/MockDataSource.m
Expand Up @@ -393,6 +393,9 @@ - (BOOL)isEmpty {
}

- (void)load:(TTURLRequestCachePolicy)cachePolicy more:(BOOL)more {
[_delegates perform:@selector(modelDidStartLoad:) withObject:self];
[self loadNames];
[_delegates perform:@selector(modelDidFinishLoad:) withObject:self];
}

- (void)invalidate:(BOOL)erase {
Expand All @@ -416,6 +419,7 @@ - (void)loadNames {
- (void)search:(NSString*)text {
[self cancel];

TT_RELEASE_SAFELY(_names);
if (text.length) {
if (_fakeSearchDuration) {
TT_INVALIDATE_TIMER(_fakeSearchTimer);
Expand All @@ -427,7 +431,6 @@ - (void)search:(NSString*)text {
[_delegates perform:@selector(modelDidFinishLoad:) withObject:self];
}
} else {
TT_RELEASE_SAFELY(_names);
[_delegates perform:@selector(modelDidChange:) withObject:self];
}
}
Expand All @@ -446,7 +449,6 @@ @implementation MockDataSource
- (id)init {
if (self = [super init]) {
_addressBook = [[MockAddressBook alloc] initWithNames:[MockAddressBook fakeNames]];
[_addressBook loadNames];
self.model = _addressBook;
}
return self;
Expand Down

0 comments on commit 668598c

Please sign in to comment.