[OGo-Developer] adding search save and create tab to document search in projects
Sebastian Reitenbach
developer@opengroupware.org
Mon, 17 Sep 2007 13:56:59 +0200
Hi,
developer@opengroupware.org wrote:
> On 17.09.2007, at 07:02, Sebastian Reitenbach wrote:
> > can't I refer to self from within the -init method
>
> If self is set you can refer to it. The usual check is:
>
> - (id)init {
> if ((self = [super init]) != nil) {
> // do stuff
> self->now = [[NSDate alloc] init];
> }
> return self;
> }
>
I have a construct like that in my init method:
- (id)init {
if ((self = [super init]) != nil) {
NSNotificationCenter *nc;
NSUserDefaults *ud;
NSArray *ap;
int max, i;
NSString *projectId;
nc = [NSNotificationCenter defaultCenter];
ud = [[self session] userDefaults];
projectId = [[self project] valueForKey:@"projectId"];
NSLog(@"init: self project: %@, projectId: %@", [self description],
projectId);
// TODO: SkyNewJobNotification???
[nc addObserver:self selector:@selector(refreshView:)
name:@"SkyNewJobNotification" object:nil];
[self setMaxSearchCount:maxSearchCountDef];
[self _setupDataSource];
self->searchArray = nil;
self->hasSearched = 0;
and here the output, when it is called:
Sep 17 13:24:22 ogo-webui-1.1 [17313]: [ERROR] SkyProject4Viewer could not
find valid project ID
Sep 17 13:24:22 ogo-webui-1.1 [17313]: init: self project: <0x0x7c128604
[SkyProject4Viewer]: name=SkyProject4Viewer>, projectId:
the -project method then starts here:
- (id)project {
id projectID;
if (self->project != nil)
return self->project;
if ((projectID = [self fileSystemNumber]) == nil) {
[self errorWithFormat:@"could not find valid project ID"];
return nil;
}
the -fileSystemNumber method looks like:
- (id)fileSystemNumber {
return [[self fileSystemAttributes] objectForKey:@"NSFileSystemNumber"];
}
and the fileSystemAttributes method looks like:
- (NSDictionary *)fileSystemAttributes {
if (self->fsinfo)
return self->fsinfo;
self->fsinfo = [[[self fileManager] fileSystemAttributesAtPath:@"/"]
copy];
//NSLog(@"self->fsinfo: %@", self->fsinfo);
return self->fsinfo;
}
and the -fileManager method looks like:
- (id<NSObject,SkyDocumentFileManager>)fileManager {
return self->fileManager;
}
but I have no clue why it is not working from within the init method, but
later it is...
kind regards
Sebastian