"IOS programming:the Big Nerd Ranch Guide" "Notes" 1

Source: Internet
Author: User

1. In the Init method of the class, you should use _value instead of Self.value to access the variable, because the initialization is in progress and the object has not been constructed yet, so it is not possible to determine whether the instance variable can be effectively assigned

2. First the specific init initialization method needs to invoke the specific Init method of the parent class, and then the other INIT methods call this particular Init method

If a subclass declares a particular Init method that is different from a specific Init method of the parent class, the subclass is required to overwrite (override) the specific Init method of the parent class and invoke the specific Init method that the subclass already has

3. In the class method, you should use self instead of the class name, so that his subclasses can also send messages

+ (Instancetype) Randomitem

{

Bnritem *newitem = [[ Self alloc] initwithitemname:randomname valueindollars:randomvalue serialnumber: Randomserialnumber];

return newitem;

}

An array in 4.objective-c can only hold OC objects, so you cannot add the underlying type and C-voice structure, you can first convert the data into OC NSNumber, Nsvalue, NSData, and add to the array

You cannot add nil to an array, but you can use the Nsnull object, nsnull to indicate that the object is nil and is typically used for special operations

[Items addobject:[nsnull null]];

5.unrecognized selector sent to instance 0x100117280 ' This error indicates that there are no methods in the instance that you want to invoke

(You sent a message to an object, and the object does not implement)

There is no namespace (namespace) in 6.OC, but rather a way to add a prefix to the class name

NS prefixes represent NeXTSTEP Company

7. #import and @import

OC compiles some system libraries and caches them, avoiding the need to recompile each time they are referenced in the header file, so you can use the @import Foundation when calling the System library's header file

"IOS programming:the Big Nerd Ranch Guide" "Notes" 1

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.