SlideShare une entreprise Scribd logo
1  sur  6
Télécharger pour lire hors ligne
CS193P                                                                            Assignment 1B
Winter 2010                                                                    Cannistraro/Shaffer

                       Assignment 1B - WhatATool (Part I)
Due Date
This assignment is due by 11:59 PM, January 13.

 Assignment
In this assignment you will be getting your feet wet with Objective-C by writing a small
command line tool. You will create and use various common framework classes in order to
become familiar with the syntax of the language.

The Objective-C runtime provides a great deal of functionality, and the gcc compiler
understands and compiles Objective-C syntax. The Objective-C language itself is a small set of
powerful syntax additions to the standard C environment.

To that end, for this assignment, you’ll be working in the most basic C environment available –
the main() function.

This assignment is divided up into several small sections. Each section is a mini-exploration of a
number of Objective-C classes and language features. Please put each section’s code in a
separate C function. The main() function should call each of the section functions in order.
Next week will add more sections to this assignment.

IMPORTANT: The assignment walkthrough begins on page 3 of this document. The
assignment walkthrough contains all of the section-specific details of what is expected.

The basic layout of your program should look something like this:

#import <Foundation/Foundation.h>

// sample function for one section, use a similar function per section
void PrintPathInfo() {
	      // Code from path info section here
}

int main (int argc, const char * argv[]) {
    NSAutoreleasepool * pool = [[NSAutoreleasePool alloc] init];

	    PrintPathInfo();                  //   Section   1
	    PrintProcessInfo();               //   Section   2
	    PrintBookmarkInfo();              //   Section   3
	    PrintIntrospectionInfo();         //   Section   4

    [pool release];
    return 0;
}

Testing
In most assignments testing of the resulting application is the primary objective. In this case,
testing/grading will be done both on the output of the tool, but also on the code of each
section.

We will be looking at the following:
1. Your project should build without errors or warnings.
2. Your project should run without crashing.

                                            Page 1 of 6
CS193P                                                                           Assignment 1B
Winter 2010                                                                   Cannistraro/Shaffer

3. Each section of the assignment describes a number of log messages that should be printed.
   These should print.
4. Each section of the assignment describes certain classes and methodology to be used to
   generate those log messages – the code generating those messages should follow the
   described methodology, and not be simply hard-coded log messages.

A note about the NSLog function. It will generate a string that is prefixed with a timestamp, the
name of the process, and the pid. It will also automatically append a newline to the log
statement.

        2009-09-23 13:49:42.275 WhatATool[360] Your message here.


This is expected. You are only being graded on the text not generated automatically by NSLog.
You do not need to attempt to suppress what NSLog prints by default.

To help make the output of your program more readable, it would be helpful to put some kind
of header or separator between each of the sections.

Hints
Hints are distributed section by section but generally, the lecture #2 notes provide some very
good clues with regards to Objective-C syntax and commonly used methods.

Another source of good information is the Apple ADC site. In particular, these documents may
be particularly helpful:

http://developer.apple.com/documentation/Cocoa/Conceptual/OOP_ObjC

http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC

http://developer.apple.com/iphone/gettingstarted/docs/objectivecprimer.action


Troubleshooting
Remember that an Objective-C NSString constant is prefixed with an @ sign. For example,
@”Hello World”. The compiler will warn, and your program will crash if you use a C string
where an NSString is required.




                                           Page 2 of 6
CS193P                                                                           Assignment 1B
Winter 2010                                                                   Cannistraro/Shaffer

Assignment Walkthrough

In Xcode, create a new Foundation Tool project. Name it WhatATool.




You will be doing the bulk of your work in the WhatATool.m file where a skeletal implementation
of main() has been provided.

You should build and test at the end of each code-writing section.

Finding Answers / Getting to documentation
Some of the information required for this exercise exists in the class documentation, not in the
course materials. You can use the Xcode documentation window to search for class
documentation as well as conceptual articles.

Open the Xcode documentation window by choosing Help > Documentation.

The leftmost section of the search bar in the documentation window lets you search APIs, Titles
or Full-Text of the documentation. For now, use the API Search. Select an appropriate Doc Set
to search, for example the “Apple iPhone OS 2.0” doc set should contain all the materials you’ll
need for this assignment.




                                           Page 3 of 6
CS193P                                                                             Assignment 1B
Winter 2010                                                                     Cannistraro/Shaffer

Section 1: Strings as file system paths

NSString has a set of methods that allow you to manipulate file system paths. You can find
them in the NSString documentation grouped under the heading “Working with paths”     .

In this section, begin with an NSString constant that is a tilde – the symbolic representation for
your home directory in Unix.

          NSString *path = @"~";

Starting with that string, find a path method that will expand the tilde in the path to the full
path to your home directory. Use that method to make a new string, and log the full path in a
format like:

          My home folder is at '/Users/pmarcos'

NSString has a method that will return an array of path components. Each element in the
returned array is a single component in the original path.

Use this method to get an array of path components for the path you just logged.

Use fast enumeration to enumerate through each item in the returned array, and log each path
component. The result should look something like:
	         /
          Users
	         pmarcos

Section Hints:
    • With string convenience methods, a common pattern is to reuse the same variable:
                NSString *aString = @"Bob";
      	         aString = [aString stringWithSomeModification];



Section 2: Finding out a bit about our own process
Look up the class NSProcessInfo in the documentation.

You will find a class method that will return an NSProcessInfo object. (In fact, you should find a
very handy code sample there as well).

From this object, you can access the name and process identifier (pid) of the process.

Log these pieces of information to the console using NSLog in the format:

          Process Name: 'WhatATool' Process ID: '4556'

Section Hints:
    • We didn’t discuss NSProcessInfo in lecture at all, so you aren’t missing any slides or notes.
      All of the information you need is in the NSProcessInfo class documentation.
    • Comparing the process info you logged with the prefix that NSLog generates can help
      verify you’re logging the correct information.



                                            Page 4 of 6
CS193P                                                                             Assignment 1B
Winter 2010                                                                     Cannistraro/Shaffer



Section 3: A little bookmark dictionary

In this section, you will build a small URL bookmark repository using a mutable dictionary. Each
key is an NSString that serves as the description of the URL, the value is an NSURL.

Create a mutable dictionary that contains the following key/value pairs:

Key (NSString)                    Value (NSURL)
Stanford University               http://www.stanford.edu
Apple                             http://www.apple.com
CS193P                            http://cs193p.stanford.edu
Stanford on iTunes U              http://itunes.stanford.edu
Stanford Mall                     http://stanfordshop.com

Enumerate through the keys of the dictionary. While enumerating through the keys, check each
key to see if it starts with @”Stanford” If it does, retrieve the NSURL object for that key from the
                                       .
dictionary, and log both the key string and the NSURL object in the following format below. If
the key does not start with @”Stanford” no output should be printed.
                                          ,

           Key: 'Stanford University' URL: 'http://www.stanford.edu'

Section Hints:
    • Use +URLWithString: to create the URL instances.
    • NSString has methods to determine if a string has a particular prefix or suffix. Remember
      to log only those keys that start with ‘Stanford’.
    • The methods for creating and adding items to a mutable dictionary are located in the
      Lecture #2 slides. Remember that an NSMutableDictionary is a subclass of NSDictionary
      and so inherits all of its methods.
    • When using a dictionary and fast enumeration, you are enumerating the keys of the
      dictionary. You can use the key to then retrieve the value. NSDictionary also defines a
      method called valueEnumerator that returns an NSEnumerator object which will directly
      enumerate the values. You can use either approach.

Section 4: Selectors, Classes and Introspection
Objective-C has a number of facilities that add to its dynamic object-oriented capabilities.  Many
of these facilities deal with determining and using an object's capabilities at runtime. 

Create a mutable array and add objects of various types to it. Create instance of the classes
we’ve used elsewhere in this assignment to populate the array: NSString, NSURL, NSProcessInfo,
NSDictionary, etc. Create some NSMutableString instances and put them in the array as well.
Feel free to create other kinds of objects also.

Iterate through the objects in the array and do the following:

      1.    Print the class name of the object.
      2.    Log if the object is member of class NSString.
      3.    Log if the object is kind of class NSString.
      4.    Log if the object responds to the selector "lowercaseString".


                                             Page 5 of 6
CS193P                                                                           Assignment 1B
Winter 2010                                                                   Cannistraro/Shaffer

      5. If the object does respond to the lowercaseString selector, log the result of asking the
         object to perform that selector (using performSelector:)

For example, if an array contained an NSString, an NSURL and an NSDictionary the output might
look something like this:

2008-01-10    20:56:03   WhatATool[360]   Class name: NSCFString
2008-01-10    20:56:03   WhatATool[360]   Is Member of NSString: NO
2008-01-10    20:56:03   WhatATool[360]   Is Kind of NSString: YES
2008-01-10    20:56:03   WhatATool[360]   Responds to lowercaseString: YES
2008-01-10    20:56:03   WhatATool[360]   lowercaseString is: hello world!
2008-01-10    20:56:03   WhatATool[360]   ======================================
2008-01-10    20:56:03   WhatATool[360]   Class name: NSURL
2008-01-10    20:56:03   WhatATool[360]   Is Member of NSString: NO
2008-01-10    20:56:03   WhatATool[360]   Is Kind of NSString: NO
2008-01-10    20:56:03   WhatATool[360]   Responds to lowercaseString: NO
2008-01-10    20:56:03   WhatATool[360]   ======================================
2008-01-10    20:56:03   WhatATool[360]   Class name: NSCFDictionary
2008-01-10    20:56:03   WhatATool[360]   Is Member of NSString: NO
2008-01-10    20:56:03   WhatATool[360]   Is Kind of NSString: NO
2008-01-10    20:56:03   WhatATool[360]   Responds to lowercaseString: NO
2008-01-10    20:56:03   WhatATool[360]   ======================================

Section Hints:
   • When you ask various classes, such as NSString, for its class name, you may not get the
      result you expect.  Your logs should report what the runtime reports back to you - don't
      worry if some of the class names may seem strange, these are implementation details of
      the NSString class. Encapsulation at work!




                                           Page 6 of 6

Contenu connexe

Tendances

Tech breakfast 18
Tech breakfast 18Tech breakfast 18
Tech breakfast 18James Leone
 
Swift Programming Language
Swift Programming LanguageSwift Programming Language
Swift Programming LanguageCihad Horuzoğlu
 
Swift Tutorial Part 2. The complete guide for Swift programming language
Swift Tutorial Part 2. The complete guide for Swift programming languageSwift Tutorial Part 2. The complete guide for Swift programming language
Swift Tutorial Part 2. The complete guide for Swift programming languageHossam Ghareeb
 
How to really obfuscate your pdf malware
How to really obfuscate your pdf malwareHow to really obfuscate your pdf malware
How to really obfuscate your pdf malwarezynamics GmbH
 
2.Getting Started with C#.Net-(C#)
2.Getting Started with C#.Net-(C#)2.Getting Started with C#.Net-(C#)
2.Getting Started with C#.Net-(C#)Shoaib Ghachi
 
1..Net Framework Architecture-(c#)
1..Net Framework Architecture-(c#)1..Net Framework Architecture-(c#)
1..Net Framework Architecture-(c#)Shoaib Ghachi
 
Hack in the Box GSEC 2016 - Reverse Engineering Swift Applications
Hack in the Box GSEC 2016 - Reverse Engineering Swift ApplicationsHack in the Box GSEC 2016 - Reverse Engineering Swift Applications
Hack in the Box GSEC 2016 - Reverse Engineering Swift Applicationseightbit
 
Introduction to mobile reversing
Introduction to mobile reversingIntroduction to mobile reversing
Introduction to mobile reversingjduart
 
Packer Genetics: The selfish code
Packer Genetics: The selfish codePacker Genetics: The selfish code
Packer Genetics: The selfish codejduart
 
Core Java Tutorial
Core Java TutorialCore Java Tutorial
Core Java TutorialJava2Blog
 
Swift Tutorial Part 1. The Complete Guide For Swift Programming Language
Swift Tutorial Part 1. The Complete Guide For Swift Programming LanguageSwift Tutorial Part 1. The Complete Guide For Swift Programming Language
Swift Tutorial Part 1. The Complete Guide For Swift Programming LanguageHossam Ghareeb
 
API workshop: Deep dive into Java
API workshop: Deep dive into JavaAPI workshop: Deep dive into Java
API workshop: Deep dive into JavaTom Johnson
 

Tendances (20)

Tech breakfast 18
Tech breakfast 18Tech breakfast 18
Tech breakfast 18
 
Swift Programming Language
Swift Programming LanguageSwift Programming Language
Swift Programming Language
 
Java notes
Java notesJava notes
Java notes
 
Java for C++ programers
Java for C++ programersJava for C++ programers
Java for C++ programers
 
Swift Tutorial Part 2. The complete guide for Swift programming language
Swift Tutorial Part 2. The complete guide for Swift programming languageSwift Tutorial Part 2. The complete guide for Swift programming language
Swift Tutorial Part 2. The complete guide for Swift programming language
 
How to really obfuscate your pdf malware
How to really obfuscate your pdf malwareHow to really obfuscate your pdf malware
How to really obfuscate your pdf malware
 
2.Getting Started with C#.Net-(C#)
2.Getting Started with C#.Net-(C#)2.Getting Started with C#.Net-(C#)
2.Getting Started with C#.Net-(C#)
 
C#.NET
C#.NETC#.NET
C#.NET
 
C sharp
C sharpC sharp
C sharp
 
1..Net Framework Architecture-(c#)
1..Net Framework Architecture-(c#)1..Net Framework Architecture-(c#)
1..Net Framework Architecture-(c#)
 
Hack in the Box GSEC 2016 - Reverse Engineering Swift Applications
Hack in the Box GSEC 2016 - Reverse Engineering Swift ApplicationsHack in the Box GSEC 2016 - Reverse Engineering Swift Applications
Hack in the Box GSEC 2016 - Reverse Engineering Swift Applications
 
AngularConf2015
AngularConf2015AngularConf2015
AngularConf2015
 
Introduction to mobile reversing
Introduction to mobile reversingIntroduction to mobile reversing
Introduction to mobile reversing
 
Introducing TypeScript
Introducing TypeScriptIntroducing TypeScript
Introducing TypeScript
 
Core Java
Core JavaCore Java
Core Java
 
Packer Genetics: The selfish code
Packer Genetics: The selfish codePacker Genetics: The selfish code
Packer Genetics: The selfish code
 
Core Java Tutorial
Core Java TutorialCore Java Tutorial
Core Java Tutorial
 
Csharp
CsharpCsharp
Csharp
 
Swift Tutorial Part 1. The Complete Guide For Swift Programming Language
Swift Tutorial Part 1. The Complete Guide For Swift Programming LanguageSwift Tutorial Part 1. The Complete Guide For Swift Programming Language
Swift Tutorial Part 1. The Complete Guide For Swift Programming Language
 
API workshop: Deep dive into Java
API workshop: Deep dive into JavaAPI workshop: Deep dive into Java
API workshop: Deep dive into Java
 

En vedette

01 introduction
01 introduction01 introduction
01 introductionrakesyh
 
Mume JQueryMobile Intro
Mume JQueryMobile IntroMume JQueryMobile Intro
Mume JQueryMobile IntroGonzalo Parra
 
iOS Development Introduction
iOS Development IntroductioniOS Development Introduction
iOS Development IntroductionGonzalo Parra
 

En vedette (6)

Mobile development
Mobile developmentMobile development
Mobile development
 
01 introduction
01 introduction01 introduction
01 introduction
 
Mume HTML5 Intro
Mume HTML5 IntroMume HTML5 Intro
Mume HTML5 Intro
 
More! @ ED-MEDIA
More! @ ED-MEDIAMore! @ ED-MEDIA
More! @ ED-MEDIA
 
Mume JQueryMobile Intro
Mume JQueryMobile IntroMume JQueryMobile Intro
Mume JQueryMobile Intro
 
iOS Development Introduction
iOS Development IntroductioniOS Development Introduction
iOS Development Introduction
 

Similaire à Assignment1 B 0

Assignment2 A
Assignment2 AAssignment2 A
Assignment2 AMahmoud
 
Article link httpiveybusinessjournal.compublicationmanaging-.docx
Article link httpiveybusinessjournal.compublicationmanaging-.docxArticle link httpiveybusinessjournal.compublicationmanaging-.docx
Article link httpiveybusinessjournal.compublicationmanaging-.docxfredharris32
 
Aspect-oriented programming in Perl
Aspect-oriented programming in PerlAspect-oriented programming in Perl
Aspect-oriented programming in Perlmegakott
 
Comp 220 ilab 5 of 7
Comp 220 ilab 5 of 7Comp 220 ilab 5 of 7
Comp 220 ilab 5 of 7ashhadiqbal
 
Ts archiving
Ts   archivingTs   archiving
Ts archivingConfiz
 
27.1.5 lab convert data into a universal format
27.1.5 lab   convert data into a universal format27.1.5 lab   convert data into a universal format
27.1.5 lab convert data into a universal formatFreddy Buenaño
 
Unit 1 - TypeScript & Introduction to Angular CLI.pptx
Unit 1 - TypeScript & Introduction to Angular CLI.pptxUnit 1 - TypeScript & Introduction to Angular CLI.pptx
Unit 1 - TypeScript & Introduction to Angular CLI.pptxMalla Reddy University
 
PRG 421 Education Specialist / snaptutorial.com
PRG 421 Education Specialist / snaptutorial.comPRG 421 Education Specialist / snaptutorial.com
PRG 421 Education Specialist / snaptutorial.comMcdonaldRyan108
 
A Project Based Lab Report On AMUZING JOKE
A Project Based Lab Report On AMUZING JOKEA Project Based Lab Report On AMUZING JOKE
A Project Based Lab Report On AMUZING JOKEDaniel Wachtel
 
CS 23001 Computer Science II Data Structures & AbstractionPro.docx
CS 23001 Computer Science II Data Structures & AbstractionPro.docxCS 23001 Computer Science II Data Structures & AbstractionPro.docx
CS 23001 Computer Science II Data Structures & AbstractionPro.docxfaithxdunce63732
 
Language-agnostic data analysis workflows and reproducible research
Language-agnostic data analysis workflows and reproducible researchLanguage-agnostic data analysis workflows and reproducible research
Language-agnostic data analysis workflows and reproducible researchAndrew Lowe
 
OverviewUsing the C-struct feature, design, implement and .docx
OverviewUsing the C-struct feature, design, implement and .docxOverviewUsing the C-struct feature, design, implement and .docx
OverviewUsing the C-struct feature, design, implement and .docxalfred4lewis58146
 
Cis 170 c ilab 7 of 7 sequential files
Cis 170 c ilab 7 of 7 sequential filesCis 170 c ilab 7 of 7 sequential files
Cis 170 c ilab 7 of 7 sequential filesCIS321
 
ActionScript 3.0 Fundamentals
ActionScript 3.0 FundamentalsActionScript 3.0 Fundamentals
ActionScript 3.0 FundamentalsSaurabh Narula
 
Basics java programing
Basics java programingBasics java programing
Basics java programingDarshan Gohel
 

Similaire à Assignment1 B 0 (20)

Assignment2 A
Assignment2 AAssignment2 A
Assignment2 A
 
Article link httpiveybusinessjournal.compublicationmanaging-.docx
Article link httpiveybusinessjournal.compublicationmanaging-.docxArticle link httpiveybusinessjournal.compublicationmanaging-.docx
Article link httpiveybusinessjournal.compublicationmanaging-.docx
 
Aspect-oriented programming in Perl
Aspect-oriented programming in PerlAspect-oriented programming in Perl
Aspect-oriented programming in Perl
 
Java lab-manual
Java lab-manualJava lab-manual
Java lab-manual
 
Objective c slide I
Objective c slide IObjective c slide I
Objective c slide I
 
iOS Application Development
iOS Application DevelopmentiOS Application Development
iOS Application Development
 
Comp 220 ilab 5 of 7
Comp 220 ilab 5 of 7Comp 220 ilab 5 of 7
Comp 220 ilab 5 of 7
 
Ts archiving
Ts   archivingTs   archiving
Ts archiving
 
27.1.5 lab convert data into a universal format
27.1.5 lab   convert data into a universal format27.1.5 lab   convert data into a universal format
27.1.5 lab convert data into a universal format
 
Unit 1 - TypeScript & Introduction to Angular CLI.pptx
Unit 1 - TypeScript & Introduction to Angular CLI.pptxUnit 1 - TypeScript & Introduction to Angular CLI.pptx
Unit 1 - TypeScript & Introduction to Angular CLI.pptx
 
PRG 421 Education Specialist / snaptutorial.com
PRG 421 Education Specialist / snaptutorial.comPRG 421 Education Specialist / snaptutorial.com
PRG 421 Education Specialist / snaptutorial.com
 
A Project Based Lab Report On AMUZING JOKE
A Project Based Lab Report On AMUZING JOKEA Project Based Lab Report On AMUZING JOKE
A Project Based Lab Report On AMUZING JOKE
 
CS 23001 Computer Science II Data Structures & AbstractionPro.docx
CS 23001 Computer Science II Data Structures & AbstractionPro.docxCS 23001 Computer Science II Data Structures & AbstractionPro.docx
CS 23001 Computer Science II Data Structures & AbstractionPro.docx
 
Language-agnostic data analysis workflows and reproducible research
Language-agnostic data analysis workflows and reproducible researchLanguage-agnostic data analysis workflows and reproducible research
Language-agnostic data analysis workflows and reproducible research
 
1. introduction to python
1. introduction to python1. introduction to python
1. introduction to python
 
OverviewUsing the C-struct feature, design, implement and .docx
OverviewUsing the C-struct feature, design, implement and .docxOverviewUsing the C-struct feature, design, implement and .docx
OverviewUsing the C-struct feature, design, implement and .docx
 
Cis 170 c ilab 7 of 7 sequential files
Cis 170 c ilab 7 of 7 sequential filesCis 170 c ilab 7 of 7 sequential files
Cis 170 c ilab 7 of 7 sequential files
 
NamingConvention
NamingConventionNamingConvention
NamingConvention
 
ActionScript 3.0 Fundamentals
ActionScript 3.0 FundamentalsActionScript 3.0 Fundamentals
ActionScript 3.0 Fundamentals
 
Basics java programing
Basics java programingBasics java programing
Basics java programing
 

Plus de Mahmoud

مهارات التفكير الإبتكاري كيف تكون مبدعا؟
مهارات التفكير الإبتكاري  كيف تكون مبدعا؟مهارات التفكير الإبتكاري  كيف تكون مبدعا؟
مهارات التفكير الإبتكاري كيف تكون مبدعا؟Mahmoud
 
كيف تقوى ذاكرتك
كيف تقوى ذاكرتككيف تقوى ذاكرتك
كيف تقوى ذاكرتكMahmoud
 
مهارات التعامل مع الغير
مهارات التعامل مع الغيرمهارات التعامل مع الغير
مهارات التعامل مع الغيرMahmoud
 
ستيفن كوفي ( ادارة الاولويات ) لايفوتكم
ستيفن كوفي ( ادارة الاولويات ) لايفوتكمستيفن كوفي ( ادارة الاولويات ) لايفوتكم
ستيفن كوفي ( ادارة الاولويات ) لايفوتكمMahmoud
 
تطوير الذاكرة تعلم كيف تحفظ 56 كلمة كل 10 دقائق
تطوير الذاكرة    تعلم كيف تحفظ 56 كلمة كل 10 دقائقتطوير الذاكرة    تعلم كيف تحفظ 56 كلمة كل 10 دقائق
تطوير الذاكرة تعلم كيف تحفظ 56 كلمة كل 10 دقائقMahmoud
 
الشخصية العبقرية
الشخصية العبقريةالشخصية العبقرية
الشخصية العبقريةMahmoud
 
مهارات كتابه السيرة الذاتيه واجتياز المقابله الشخصيه
مهارات كتابه السيرة الذاتيه واجتياز المقابله الشخصيهمهارات كتابه السيرة الذاتيه واجتياز المقابله الشخصيه
مهارات كتابه السيرة الذاتيه واجتياز المقابله الشخصيهMahmoud
 
مهارات التفكير الإبتكاري كيف تكون مبدعا؟
مهارات التفكير الإبتكاري  كيف تكون مبدعا؟مهارات التفكير الإبتكاري  كيف تكون مبدعا؟
مهارات التفكير الإبتكاري كيف تكون مبدعا؟Mahmoud
 
مهارات التعامل مع الغير
مهارات التعامل مع الغيرمهارات التعامل مع الغير
مهارات التعامل مع الغيرMahmoud
 
تطوير الذاكرة تعلم كيف تحفظ 56 كلمة كل 10 دقائق
تطوير الذاكرة    تعلم كيف تحفظ 56 كلمة كل 10 دقائقتطوير الذاكرة    تعلم كيف تحفظ 56 كلمة كل 10 دقائق
تطوير الذاكرة تعلم كيف تحفظ 56 كلمة كل 10 دقائقMahmoud
 
كيف تقوى ذاكرتك
كيف تقوى ذاكرتككيف تقوى ذاكرتك
كيف تقوى ذاكرتكMahmoud
 
ستيفن كوفي ( ادارة الاولويات ) لايفوتكم
ستيفن كوفي ( ادارة الاولويات ) لايفوتكمستيفن كوفي ( ادارة الاولويات ) لايفوتكم
ستيفن كوفي ( ادارة الاولويات ) لايفوتكمMahmoud
 
الشخصية العبقرية
الشخصية العبقريةالشخصية العبقرية
الشخصية العبقريةMahmoud
 
Accident Investigation
Accident InvestigationAccident Investigation
Accident InvestigationMahmoud
 
Investigation Skills
Investigation SkillsInvestigation Skills
Investigation SkillsMahmoud
 
Building Papers
Building PapersBuilding Papers
Building PapersMahmoud
 
Appleipad 100205071918 Phpapp02
Appleipad 100205071918 Phpapp02Appleipad 100205071918 Phpapp02
Appleipad 100205071918 Phpapp02Mahmoud
 
Operatingsystemwars 100209023952 Phpapp01
Operatingsystemwars 100209023952 Phpapp01Operatingsystemwars 100209023952 Phpapp01
Operatingsystemwars 100209023952 Phpapp01Mahmoud
 
A Basic Modern Russian Grammar
A Basic Modern Russian Grammar A Basic Modern Russian Grammar
A Basic Modern Russian Grammar Mahmoud
 

Plus de Mahmoud (20)

مهارات التفكير الإبتكاري كيف تكون مبدعا؟
مهارات التفكير الإبتكاري  كيف تكون مبدعا؟مهارات التفكير الإبتكاري  كيف تكون مبدعا؟
مهارات التفكير الإبتكاري كيف تكون مبدعا؟
 
كيف تقوى ذاكرتك
كيف تقوى ذاكرتككيف تقوى ذاكرتك
كيف تقوى ذاكرتك
 
مهارات التعامل مع الغير
مهارات التعامل مع الغيرمهارات التعامل مع الغير
مهارات التعامل مع الغير
 
ستيفن كوفي ( ادارة الاولويات ) لايفوتكم
ستيفن كوفي ( ادارة الاولويات ) لايفوتكمستيفن كوفي ( ادارة الاولويات ) لايفوتكم
ستيفن كوفي ( ادارة الاولويات ) لايفوتكم
 
تطوير الذاكرة تعلم كيف تحفظ 56 كلمة كل 10 دقائق
تطوير الذاكرة    تعلم كيف تحفظ 56 كلمة كل 10 دقائقتطوير الذاكرة    تعلم كيف تحفظ 56 كلمة كل 10 دقائق
تطوير الذاكرة تعلم كيف تحفظ 56 كلمة كل 10 دقائق
 
الشخصية العبقرية
الشخصية العبقريةالشخصية العبقرية
الشخصية العبقرية
 
مهارات كتابه السيرة الذاتيه واجتياز المقابله الشخصيه
مهارات كتابه السيرة الذاتيه واجتياز المقابله الشخصيهمهارات كتابه السيرة الذاتيه واجتياز المقابله الشخصيه
مهارات كتابه السيرة الذاتيه واجتياز المقابله الشخصيه
 
مهارات التفكير الإبتكاري كيف تكون مبدعا؟
مهارات التفكير الإبتكاري  كيف تكون مبدعا؟مهارات التفكير الإبتكاري  كيف تكون مبدعا؟
مهارات التفكير الإبتكاري كيف تكون مبدعا؟
 
مهارات التعامل مع الغير
مهارات التعامل مع الغيرمهارات التعامل مع الغير
مهارات التعامل مع الغير
 
تطوير الذاكرة تعلم كيف تحفظ 56 كلمة كل 10 دقائق
تطوير الذاكرة    تعلم كيف تحفظ 56 كلمة كل 10 دقائقتطوير الذاكرة    تعلم كيف تحفظ 56 كلمة كل 10 دقائق
تطوير الذاكرة تعلم كيف تحفظ 56 كلمة كل 10 دقائق
 
كيف تقوى ذاكرتك
كيف تقوى ذاكرتككيف تقوى ذاكرتك
كيف تقوى ذاكرتك
 
ستيفن كوفي ( ادارة الاولويات ) لايفوتكم
ستيفن كوفي ( ادارة الاولويات ) لايفوتكمستيفن كوفي ( ادارة الاولويات ) لايفوتكم
ستيفن كوفي ( ادارة الاولويات ) لايفوتكم
 
الشخصية العبقرية
الشخصية العبقريةالشخصية العبقرية
الشخصية العبقرية
 
Accident Investigation
Accident InvestigationAccident Investigation
Accident Investigation
 
Investigation Skills
Investigation SkillsInvestigation Skills
Investigation Skills
 
Building Papers
Building PapersBuilding Papers
Building Papers
 
Appleipad 100205071918 Phpapp02
Appleipad 100205071918 Phpapp02Appleipad 100205071918 Phpapp02
Appleipad 100205071918 Phpapp02
 
Operatingsystemwars 100209023952 Phpapp01
Operatingsystemwars 100209023952 Phpapp01Operatingsystemwars 100209023952 Phpapp01
Operatingsystemwars 100209023952 Phpapp01
 
A Basic Modern Russian Grammar
A Basic Modern Russian Grammar A Basic Modern Russian Grammar
A Basic Modern Russian Grammar
 
Teams Ar
Teams ArTeams Ar
Teams Ar
 

Dernier

Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 

Dernier (20)

Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 

Assignment1 B 0

  • 1. CS193P Assignment 1B Winter 2010 Cannistraro/Shaffer Assignment 1B - WhatATool (Part I) Due Date This assignment is due by 11:59 PM, January 13. Assignment In this assignment you will be getting your feet wet with Objective-C by writing a small command line tool. You will create and use various common framework classes in order to become familiar with the syntax of the language. The Objective-C runtime provides a great deal of functionality, and the gcc compiler understands and compiles Objective-C syntax. The Objective-C language itself is a small set of powerful syntax additions to the standard C environment. To that end, for this assignment, you’ll be working in the most basic C environment available – the main() function. This assignment is divided up into several small sections. Each section is a mini-exploration of a number of Objective-C classes and language features. Please put each section’s code in a separate C function. The main() function should call each of the section functions in order. Next week will add more sections to this assignment. IMPORTANT: The assignment walkthrough begins on page 3 of this document. The assignment walkthrough contains all of the section-specific details of what is expected. The basic layout of your program should look something like this: #import <Foundation/Foundation.h> // sample function for one section, use a similar function per section void PrintPathInfo() { // Code from path info section here } int main (int argc, const char * argv[]) { NSAutoreleasepool * pool = [[NSAutoreleasePool alloc] init]; PrintPathInfo(); // Section 1 PrintProcessInfo(); // Section 2 PrintBookmarkInfo(); // Section 3 PrintIntrospectionInfo(); // Section 4 [pool release]; return 0; } Testing In most assignments testing of the resulting application is the primary objective. In this case, testing/grading will be done both on the output of the tool, but also on the code of each section. We will be looking at the following: 1. Your project should build without errors or warnings. 2. Your project should run without crashing. Page 1 of 6
  • 2. CS193P Assignment 1B Winter 2010 Cannistraro/Shaffer 3. Each section of the assignment describes a number of log messages that should be printed. These should print. 4. Each section of the assignment describes certain classes and methodology to be used to generate those log messages – the code generating those messages should follow the described methodology, and not be simply hard-coded log messages. A note about the NSLog function. It will generate a string that is prefixed with a timestamp, the name of the process, and the pid. It will also automatically append a newline to the log statement. 2009-09-23 13:49:42.275 WhatATool[360] Your message here. This is expected. You are only being graded on the text not generated automatically by NSLog. You do not need to attempt to suppress what NSLog prints by default. To help make the output of your program more readable, it would be helpful to put some kind of header or separator between each of the sections. Hints Hints are distributed section by section but generally, the lecture #2 notes provide some very good clues with regards to Objective-C syntax and commonly used methods. Another source of good information is the Apple ADC site. In particular, these documents may be particularly helpful: http://developer.apple.com/documentation/Cocoa/Conceptual/OOP_ObjC http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC http://developer.apple.com/iphone/gettingstarted/docs/objectivecprimer.action Troubleshooting Remember that an Objective-C NSString constant is prefixed with an @ sign. For example, @”Hello World”. The compiler will warn, and your program will crash if you use a C string where an NSString is required. Page 2 of 6
  • 3. CS193P Assignment 1B Winter 2010 Cannistraro/Shaffer Assignment Walkthrough In Xcode, create a new Foundation Tool project. Name it WhatATool. You will be doing the bulk of your work in the WhatATool.m file where a skeletal implementation of main() has been provided. You should build and test at the end of each code-writing section. Finding Answers / Getting to documentation Some of the information required for this exercise exists in the class documentation, not in the course materials. You can use the Xcode documentation window to search for class documentation as well as conceptual articles. Open the Xcode documentation window by choosing Help > Documentation. The leftmost section of the search bar in the documentation window lets you search APIs, Titles or Full-Text of the documentation. For now, use the API Search. Select an appropriate Doc Set to search, for example the “Apple iPhone OS 2.0” doc set should contain all the materials you’ll need for this assignment. Page 3 of 6
  • 4. CS193P Assignment 1B Winter 2010 Cannistraro/Shaffer Section 1: Strings as file system paths NSString has a set of methods that allow you to manipulate file system paths. You can find them in the NSString documentation grouped under the heading “Working with paths” . In this section, begin with an NSString constant that is a tilde – the symbolic representation for your home directory in Unix. NSString *path = @"~"; Starting with that string, find a path method that will expand the tilde in the path to the full path to your home directory. Use that method to make a new string, and log the full path in a format like: My home folder is at '/Users/pmarcos' NSString has a method that will return an array of path components. Each element in the returned array is a single component in the original path. Use this method to get an array of path components for the path you just logged. Use fast enumeration to enumerate through each item in the returned array, and log each path component. The result should look something like: / Users pmarcos Section Hints: • With string convenience methods, a common pattern is to reuse the same variable: NSString *aString = @"Bob"; aString = [aString stringWithSomeModification]; Section 2: Finding out a bit about our own process Look up the class NSProcessInfo in the documentation. You will find a class method that will return an NSProcessInfo object. (In fact, you should find a very handy code sample there as well). From this object, you can access the name and process identifier (pid) of the process. Log these pieces of information to the console using NSLog in the format: Process Name: 'WhatATool' Process ID: '4556' Section Hints: • We didn’t discuss NSProcessInfo in lecture at all, so you aren’t missing any slides or notes. All of the information you need is in the NSProcessInfo class documentation. • Comparing the process info you logged with the prefix that NSLog generates can help verify you’re logging the correct information. Page 4 of 6
  • 5. CS193P Assignment 1B Winter 2010 Cannistraro/Shaffer Section 3: A little bookmark dictionary In this section, you will build a small URL bookmark repository using a mutable dictionary. Each key is an NSString that serves as the description of the URL, the value is an NSURL. Create a mutable dictionary that contains the following key/value pairs: Key (NSString) Value (NSURL) Stanford University http://www.stanford.edu Apple http://www.apple.com CS193P http://cs193p.stanford.edu Stanford on iTunes U http://itunes.stanford.edu Stanford Mall http://stanfordshop.com Enumerate through the keys of the dictionary. While enumerating through the keys, check each key to see if it starts with @”Stanford” If it does, retrieve the NSURL object for that key from the . dictionary, and log both the key string and the NSURL object in the following format below. If the key does not start with @”Stanford” no output should be printed. , Key: 'Stanford University' URL: 'http://www.stanford.edu' Section Hints: • Use +URLWithString: to create the URL instances. • NSString has methods to determine if a string has a particular prefix or suffix. Remember to log only those keys that start with ‘Stanford’. • The methods for creating and adding items to a mutable dictionary are located in the Lecture #2 slides. Remember that an NSMutableDictionary is a subclass of NSDictionary and so inherits all of its methods. • When using a dictionary and fast enumeration, you are enumerating the keys of the dictionary. You can use the key to then retrieve the value. NSDictionary also defines a method called valueEnumerator that returns an NSEnumerator object which will directly enumerate the values. You can use either approach. Section 4: Selectors, Classes and Introspection Objective-C has a number of facilities that add to its dynamic object-oriented capabilities.  Many of these facilities deal with determining and using an object's capabilities at runtime.  Create a mutable array and add objects of various types to it. Create instance of the classes we’ve used elsewhere in this assignment to populate the array: NSString, NSURL, NSProcessInfo, NSDictionary, etc. Create some NSMutableString instances and put them in the array as well. Feel free to create other kinds of objects also. Iterate through the objects in the array and do the following: 1. Print the class name of the object. 2. Log if the object is member of class NSString. 3. Log if the object is kind of class NSString. 4. Log if the object responds to the selector "lowercaseString". Page 5 of 6
  • 6. CS193P Assignment 1B Winter 2010 Cannistraro/Shaffer 5. If the object does respond to the lowercaseString selector, log the result of asking the object to perform that selector (using performSelector:) For example, if an array contained an NSString, an NSURL and an NSDictionary the output might look something like this: 2008-01-10 20:56:03 WhatATool[360] Class name: NSCFString 2008-01-10 20:56:03 WhatATool[360] Is Member of NSString: NO 2008-01-10 20:56:03 WhatATool[360] Is Kind of NSString: YES 2008-01-10 20:56:03 WhatATool[360] Responds to lowercaseString: YES 2008-01-10 20:56:03 WhatATool[360] lowercaseString is: hello world! 2008-01-10 20:56:03 WhatATool[360] ====================================== 2008-01-10 20:56:03 WhatATool[360] Class name: NSURL 2008-01-10 20:56:03 WhatATool[360] Is Member of NSString: NO 2008-01-10 20:56:03 WhatATool[360] Is Kind of NSString: NO 2008-01-10 20:56:03 WhatATool[360] Responds to lowercaseString: NO 2008-01-10 20:56:03 WhatATool[360] ====================================== 2008-01-10 20:56:03 WhatATool[360] Class name: NSCFDictionary 2008-01-10 20:56:03 WhatATool[360] Is Member of NSString: NO 2008-01-10 20:56:03 WhatATool[360] Is Kind of NSString: NO 2008-01-10 20:56:03 WhatATool[360] Responds to lowercaseString: NO 2008-01-10 20:56:03 WhatATool[360] ====================================== Section Hints: • When you ask various classes, such as NSString, for its class name, you may not get the result you expect.  Your logs should report what the runtime reports back to you - don't worry if some of the class names may seem strange, these are implementation details of the NSString class. Encapsulation at work! Page 6 of 6