// // BPNoteDocument.m // Attempt2 // // Created by Bea on 10/05/05. // Copyright 2005 __MyCompanyName__. All rights reserved. // #import "BPNoteDocument.h" #import "BPPerson.h" @implementation BPNoteDocument - (id)initWithBodyText:(NSString *)text { [super initWithAuthor:[BPPerson personThatsMe] date:[NSDate date] label:@"" body:text]; return self; } - (NSString *)generateLabel { // make a label that's the first 60 characters, or the first sentence, // of the note (whichever is smaller) if ([body isEqual:@""]) return [NSString string]; if ([body length] > 60) { // return 1st sentence if a "." is present NSArray *sentences = [body componentsSeparatedByString:@"."]; if ([sentences count] > 0) return [sentences objectAtIndex:0]; return [body substringToIndex:60]; } else { return body; } } - (void)dealloc { NSLog(@"Destroying notedoc"); [body release]; [super dealloc]; } #pragma - #pragma archival - (void)encodeWithCoder:(NSCoder *)coder { [super encodeWithCoder:coder]; } - (id)initWithCoder:(NSCoder *)coder { [super initWithCoder:coder]; return self; } @end