Assignment 1

Due Date

Tuesday, September 15th — 11:59pm

Backgound

Xcode and Objective-C form the foundation by which all iPhone and iPod touch applications are built. This project is designed to give you some hands on experience with…

  • Utilizing Xcode as a development environment
  • Compiling Objective-C source code
  • Foundation framework classes
  • Writing your own custom Objective-C classes

Task

Most modern web browsers have a bookmarking mechanism that allows you to bookmark pages for easy access. For this assignment you are going to model a BookmarkManager class that provides mechanisms for storing and retrieving bookmark data. Specifically, this class will support storing a URL (i.e. https://cs491f09.wordpress.com/), a title for that URL (i.e. iPhone and iPod touch Development Homepage) as well as a set of tags which can be used to describe that page (i.e. umbc,course,computer science,iphone).

For this assignment, you will need to implement a class called BookmarkManager. This class must implement the following methods…


- (BOOL)addBookmarkURL:(NSURL *)url title:(NSString *)title;

Adds the specifed url and title to the bookmark collection without any associated tags. This method should return YES for a successful insert (neither the url nor the title were already present in collection), or NO if the specified url or title is already contained in the collection.


- (BOOL)addBookmarkURL:(NSURL *)url title:(NSString *)title tags:(NSString *)tags;

Adds the specifed url and title to the bookmark collection with the specified tags. Tags will be passed in as a comma separated list of tag names (i.e. “umbc,cmsc,iphone”). If there is only a single tag it will not contain a comma (i.e. just “umbc”). The tags string is guaranteed to be well formatted and will always contain at least 1 value. This method should return YES for a successful insert (neither the url nor the title were already present in collection), or NO if the specified url or title is already contained in the collection.


- (void)listBookmarks;

This method will display all of the bookmarks in the collection. Sample output is shown below:

2009-09-08 17:07:21.518 Project1[1187:10b] Google <http://www.google.com/&gt; - Tags: search
2009-09-08 17:07:21.520 Project1[1187:10b] Bing <http://www.bing.com/&gt; - No Tags
2009-09-08 17:07:21.521 Project1[1187:10b] iPhone Dev Course Homepage <https://cs491f09.wordpress.com/&gt; - Tags: umbc, cmsc, iphone
2009-09-08 17:07:21.522 Project1[1187:10b] iPhone Dev Center <http://developer.apple.com/iphone/&gt; - Tags: apple, iphone
2009-09-08 17:07:21.522 Project1[1187:10b] UMBC Homepage <http://www.umbc.edu/&gt; - Tags: umbc


- (void)listBookmarksWithTag:(NSString *)tag;

This method will display only bookmarks that contain the exact tag passed in. You are guaranteed that the tag will be a single value which may or may not appear in the collection (i.e. “umbc”). Sample output is shown below:

2009-09-08 17:07:21.521 Project1[1187:10b] iPhone Dev Course Homepage <https://cs491f09.wordpress.com/&gt; - Tags: umbc, cmsc, iphone
2009-09-08 17:07:21.522 Project1[1187:10b] iPhone Dev Center <http://developer.apple.com/iphone/&gt; - Tags: apple, iphone


- (BOOL)removeBookmarkWithURL:(NSURL *)url;

Removes the bookmark with the specified url from the collection. This method should return YES for a successful removal (there was a bookmark with the url present in collection), or NO if the specified url was not contained in the collection.


- (BOOL)removeBookmarkWithTitle:(NSString *)title;

Removes the bookmark with the specified title from the collection. This method should return YES for a successful removal (there was a bookmark with the title present in collection), or NO if the specified title was not contained in the collection.


- (NSURL *)urlForTitle:(NSString *)title;

Returns the URL for the bookmark with the specified title. If the title is not present in the collection, this method should return nil.


- (NSArray *)tagsForTitle:(NSString *)title;

Returns the tags (an NSArary of NSStrings) for the bookmark with the specified title. If the title is not present in the collection, this method should return nil. If no tags are associated with the specified title, this method should return an empty NSArary.


- (NSString *)titleForURL:(NSURL *)url;

Returns the title for the bookmark with the specified url. If the url is not present in the collection, this method should return nil.


- (NSArray *)tagsForURL:(NSURL *)url;

Returns the tags (an NSArary of NSStrings) for the bookmark with the specified url. If the url is not present in the collection, this method should return nil. If no tags are associated with the specified url, this method should return an empty NSArary.


- (int)count;

Returns the number of bookmarks in the collection. The count should also be implemented as a readonly property, such that a user of this class could utilize the dot notation to retrieve this value (i.e. int num = bookmarks.count).


- (id)init;

You should also provide a no-argument initialization method. You’re welcome to implement additional init methods, but we will instantiate your class in our main with the no-argument constructor.

You are encouraged to develop your own main which exercises the methods of this class. When the project is graded we will swap in our own main to test the robustness of your class.

Notes on Naming

Since we will be using our own main to test your class, it is very important that you name your class BookmarkManager, implement it in files called BookmarkManager.[mh] and name your methods exactly as they are listed above (copy and paste is your friend).

Behind the scenes you are welcome to implement additional methods and classes to support the BookmarkManager class. However, these internal workings should not be exposed to the outside world — meaning that the user of this class should never have to call anything other than the methods listed above, nor should they have to include any files other than BookmarkManager.h in their main to use the class.

Getting Started

If using Xcode 3.1.x (the version in ENG005), create a new project by selecting File → New Project… then under Mac OS X select Command Line Utility and select Foundation Tool project. Select Choose…

Creating a Foundation Project under Xcode 3.1.x

Creating a Foundation Project under Xcode 3.1.x

If using Xcode 3.2 (if you’re running Snow Leopard), create a new project by selecting File → New Project… then under Mac OS X select Application and select Command Line Tool. Lastly, change the Type drop-down to Foundation, then select Choose…

Creating a Foundation Project under Xcode 3.2

Creating a Foundation Project under Xcode 3.2

Once you’ve selected the correct project type (regardless of the version of Xcode you are using) name the project “Project1”, then press Save. If you are working on the lab machines, you’ll want to expand the disclosure arrow and save to a location under your AFS home directory (if you simply save it to the Desktop your work will be lost when you logout). There should be a symlink on the Desktop which you can use to navigate to your home directory.

Naming the Project

Naming the Project

This will build out a small project with a file called “Project1.m” containing a main consisting of a simple “Hello World” implementation.

Next you’ll want to have Xcode stub out your BookmarkManager class for you. To do this, simply right click (or control click) under Sources and select Add → New File…

Add → New File...

Add → New File...

If using Xcode 3.1.x from Mac OS X select Cocoa and then select Objective-C class. Click Next.

New Objective-C Class under Xcode 3.1.x

New Objective-C Class under Xcode 3.1.x

If using Xcode 3.2 from Mac OS X select Cocoa Class then select Objective-C class from the list and be sure that the Subclass of drop-down specifies NSObject. Then click Next.

New Objective-C Class

New Objective-C Class under Xcode 3.2

Next, name the file BookmarkManager.m, ensure the also create BookmarkManager.h checkbox is selected, the default location should automatically be under the project locaction you selected, Add to Project should specify Project1 and the Target Project1 should be checked. Click Finish to create the classes. You should now have a BookmarkManager.m and BookmarkManager.h file stubbed out for you in the Sources folder.

File Name

File Name

You should now be ready to start implementing the class and test it using Project1.m.

Grading

Your projects will be graded on the following criteria:

  • Correctness of application
  • Adherence to Objective-C and iPhone coding conventions
  • Neatly formatted and indented code
  • Well documented header files
  • Absence of significant performance issues
  • Absence of memory leaks

Submission

To prep your project for submission, you’ll need to do some tidying up first. Using finder, if you navigate to the directory containing your project, you will notice that there is a directory called “build”.

Project Directory Structure

Project Directory Structure

This directory is created automatically by Xcode and contains the your compiled application. So, we’re going to delete the directory — you can easily do this with a Command-Delete sequence from within Finder. Once the build directory has been removed, you need to zip up your entire project directory. To do this right click (or control click) on the project folder and select “Compress Project1”.

Compress Project

Compress Project

This will create a Project1.zip file that contains your project.

Compressed Zipfile

Compressed Zipfile

All that’s left is to use the actual submit command to hand in the assignment. To do so, open a Terminal and navigate to your zip file. Once there issue the command:

submit cs491i assignment1 Project1.zip

If developing on your own Mac, you’ll need to transfer the file into your GL account (via SCP) and then SSH into GL and issue the submit command.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: