Question

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.

Was it helpful?

Solution

In a super simple form (i.e. there are many ways you can build on this to make it scalable):

  1. If each note is text, create an object with properties for the text and the tags
  2. Make the tags property an array of strings
  3. Store the notes in an array initially (archive to save to disk, or just practice with a non-saved version)
  4. Make the user enter the tags (auto-tagging is an interesting topic...)
  5. Consider using a token field (google for 3rd party implementations) for tag entry

Now, when a user starts a search for tagged content, iterate through each of the notes you have and run a predicate on the tag array. This could be done using NSPredicate, or you could ensure that all tags are saved in lower case and, to start with, require exact matching - so you could use '[tagArray containsObject:userEnteredTag];`

Then:

  1. Look at real predicates
  2. Look at Core Data (or SQLite if you love it)

OTHER TIPS

You will need to use Core Data or SQLite3. Personally I would use SQLite but it is down to preference. I have used both but if you have any SQL knowledge then I wouldn't use Core Data. Having created an app with CoreData and using a lot of NSPredicates I found that the app had a lot of bug that appeared over time. I changed it to use SQLite and now it runs perfectly.

As you are new to iOS I would recommend you take a look at Ray Wenderlich's tutorials. I learnt a lot from there.

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top