0

I'm an absolute newbie on iOS Development at the minute so please pardon me if this seems like such a simple question to ask.

I want to build a project - almost like a note taking application - in which the user will be able to associate tags to their inputs. I'm sure many have seen them before - it's used in things like hashtags, or to give an example of an iOS app - Journalling apps like DayOne have it. It's basically used to generate tags for easy retrieval of a particular article.

My question is - how do you go about creating these kinds of tags? Particularly - how do you implement the tagging system that can generate custom tags for articles in the app?

Is it something that is built into Cocoa/SDK or do i have to look at something more complex like Core Data (NSPredicates) to learn how to create something like that?

OR is it something that has to be done programatically rather than a built in system in SDK?

Thanks.

4

2 回答 2

0

您将需要使用 Core Data 或 SQLite3。我个人会使用 SQLite,但这取决于偏好。我都使用过,但如果你有任何 SQL 知识,那么我不会使用 Core Data。使用 CoreData 创建了一个应用程序并使用了很多 NSPredicates,我发现该应用程序有很多随着时间的推移出现的错误。我将其更改为使用 SQLite,现在它运行完美。

由于您是 iOS 新手,我建议您查看 Ray Wenderlich 的教程。我从那里学到了很多东西。

http://www.raywenderlich.com/913/sqlite-tutorial-for-ios-making-our-app

于 2013-09-30T11:53:55.023 回答
0

以超级简单的形式(即,您可以通过多种方式构建它以使其可扩展):

  1. 如果每个注释都是文本,则创建一个具有文本和标签属性的对象
  2. 使 tags 属性成为字符串数组
  3. 最初将笔记存储在数组中(存档以保存到磁盘,或者只是使用未保存的版本进行练习)
  4. 让用户输入标签(自动标签是一个有趣的话题......)
  5. 考虑使用token field(google for 3rd party implementations)进行标签输入

现在,当用户开始搜索标记的内容时,遍历您拥有的每个注释并在标记数组上运行谓词。这可以使用 来完成NSPredicate,或者您可以确保所有标签都以小写形式保存,并且首先需要完全匹配 - 所以您可以使用 '[tagArray containsObject:userEnteredTag];`

然后:

  1. 查看真正的谓词
  2. 看看 Core Data(或者 SQLite,如果你喜欢它)
于 2013-09-30T12:04:45.840 回答