iOS Learning 2

Source: Internet
Author: User

1. #import, the difference between # include and @class

All refer to a class, which defines the difference at all: #include, #import会把所有的copy一份到该文件

#import比 the benefits of # include, import does not cause cross-variation (the same file is not referenced multiple times)

In Objective-c, #import is used as an improved version of the #include directive. In addition, #import determine that a file can only be imported once, which allows you to have no problem with recursive inclusion.

In general, use the #import when importing the objective-c header file, including the C header file with # include.

@class just stating that such

2 typedef effects

Shorthand code. General structure, block code blocks are often used. Compile-time substitution.

Unlike # define, the # define is executed before compilation.

Attention:
typedef PSTR CHAR *

The meaning of the const PSTR P2 is: limited number

A variable of type char * P2 is read-only and therefore p2++ error. -------read-only. @!

3 Dynamic Binding

Used for polymorphism. The ID type. At compile time, you can

1. Short answer (2 points per channel) score of 20

1.1 briefly describes the roles and differences of #import and @class.

1.2 Briefly describes the role of typedef.

1.3 What is dynamic binding.

1.4 Enumerate the pros and cons of Objective-c.

1.5 briefly describes the function of Alloc,dealoc retain,release.

1.6 What is the difference between using point syntax and direct assignment, such as [email protected] "student" and [email protected] "student"

1.7copy,assign,retain are used under what circumstances.

Does 1.8objective-c have a private method? If not, how to implement if there is a declaration.

The role of the 1.9static keyword.

The 1.10 class method differs from the object created by the instance method.


2. Algorithm total 30 points


2.1

Sorts the specified array in descending order, and the contents of the array are strings (5 points)

+ (nsarray*) Sortarray: (nsarray*) array;


2.2

Print 99 multiplication table with NSLog (5 points)

+ (void) printtable;


2.3

Parses the specified string (separated by a space between words), returns the number of occurrences of all words in it, and returns a dictionary of words as a key with the number of occurrences as a value ((10 points)

+ (nsdictionary*) WordCount: (nsstring*) filecontent;


2.4

Print based on what you enter (10 points)

+ (void) Print: (Nsinteger) Count blankstring: (nsstring*) blankstring flagstring: (nsstring*) flagstring;

such as [Class Print:5 blankstring:@ "+" flagstring:@ "#"];

+ + # + +

+ # + # +

# + + + #

+ # + # +

+ + # + +


3. Class Design


3.1 Company class and employee category (25 points)

Staff (5 min)


Member variables


Name (nsstring) name


Length of Employment (cgfloat) year (based on the time of entry and the company's founding time)


Department (nsstring) department


Post (NSString) post


Leadership (staff) leader


Entry (NSString) time


Method


Three parameter initialization methods (name, entry time, department), other values can be assigned by point syntax

-(ID) Initname: (nsstring*) name time: (nsstring*) Time Department: (nsstring*) department;


Printing method

Format "Name:%@, Seniority:%f, Department:%@, Position:%@, Entry time:%@"

-(void) print;


Company (20 points)


Member variables


Company Name (nsstring) name


Date of establishment (NSString) Createtime


Corporate (staff) leader


The department name is the dictionary key, and the value is an array of all employees for this department

Department (Nsmutabledictionary) Departmentarray


Method


An initialization method for a parameter (the parameter is an array type, contains three values, respectively, the company name, set up time)


Add a new employee if the employee's department does not exist then create, if the employee is the leader of this department to notify all other employees, cannot add employees repeatedly (name and employee who are the same as the entry time)

-(void) Addstaff: (staff*) staff; (5 points)


Find employees by name and entry time

-(staff*) Findstaff: (nsstring*) name time: (nsstring*) time (5 minutes)


Change the assigned employee to a new department

-(BOOL) Changedepartment: (staff*) Staff Department: (nsstring*) department; (5 points)


Test method Create company, create three departments, at least two employees per department, test all methods once

+ (void) Test;


3.2 Bookmarks and their management class (70 points)


Urlitem Class (Bookmark Class) (5 points)


Member variables


Unique index value ID (nsnumber type)

URL URLs (String)

Header title (string)

Star Stars (NSNumber type)

Description Description (String)

Number of visits Vistis (integer)


Tagitem Class (Label Class) (5 points)


Member variables


Unique index value ID (nsnumber type)

Label name Name (string)

Number of visits Vistis (integer)


Bookmark Class (Bookmark management Class)


Method


1. Add bookmarks: Parameters have URL, title, label (5 points)


Where the label is a comma separated by a number of words or words composed of strings, such as @ "star, my favorite, gossip"


2. Delete bookmarks (you can delete bookmarks with Id,url two methods) (5 points)

3. Query bookmarks (can use Id,url, tag name to find bookmarks) (5 points)


4. Modify bookmarks (5 points)

The parameter that determines the bookmark to be modified may be an ID or URL

The value to be modified may be the title, creation time, or label (renaming or replacing the original label)


5. Get all bookmarks (can be sorted by star rating, number of visits) (may have no tagged bookmarks) (5 points)

6. Get all tags (can be sorted by tag name, number of visits) (5 points)


7. Remove the label with the tag name (all bookmarks with this tag are deleted) (10 points)


8 Printing function (5 points)


Print all labels for a bookmark

Print all bookmarks for one label

Print all bookmarks

Print all labels


9 Add tags to an existing bookmark (5 points)


10. Test method, complete all your implementation methods of testing (10)

iOS Learning 2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.