我正在开发一个阅读文本内容的应用程序。在那个阅读器中,我需要像 iBooks 一样的便笺功能。我想将这些笔记保存在我的设备中。如何保存输入的文本内容?以及如何再次重新打开输入的文本(即)在哪里/如何存储输入的文本?
UIMenuItem *item = [[[UIMenuItem alloc] initWithTitle: @"Wikipedia" action: @selector(wiki:)] autorelease];
UIMenuItem *item1 = [[[UIMenuItem alloc] initWithTitle: @"Dictionary" action: @selector(dict:)] autorelease];
UIMenuItem *item2 = [[[UIMenuItem alloc] initWithTitle: @"Highlight" action: @selector(highlighting:)] autorelease];
UIMenuItem *item3 = [[[UIMenuItem alloc] initWithTitle: @"Notes" action: @selector(noteMaking:)] autorelease];
[menuController setTargetRect:CGRectMake(100, 100, 320, 100) inView:self.view];
[menuController setMenuVisible:YES animated:YES];
[menuController setMenuItems: [NSArray arrayWithObjects: item,item1,item2,item3,nil]];
-(void) noteMaking:(id) sender
{
notes = [[UITextView alloc] initWithFrame:CGRectMake(100, 100, 620, 520)];
notes.text = @"";
notes.scrollEnabled = YES;
[self.view addSubview:notes];
}
CoreData 是最好、最可靠的数据管理框架。专门用于非常大量的数据。出于您的目的,我建议您使用书籍、页面和注释表创建数据库。CoreData 将从它创建实体类,稍后您可以轻松地持久化数据。
.plit 文件可以存储在您的 Document 目录中,并且可以随时检索和保存。当您阅读它时,它将被解析,您将获得易于遍历的 NSDictionary 对象。虽然这对您来说不是一个很好的选择,因为您将处理大量数据并且 CRD 操作将非常昂贵。