Δευτέρα 23 Απριλίου 2012

Chapter 2 - notes


  • a method is a chunk of code that can be executed 
  • a message is the act of asking a class or object to execute a method. 
  • reveal the log navigator using Command-7
  • At NSLog the first argument is required and must be an NSString instance. This instance is called the format string and it contains text and a number of tokens. When %@ is encountered in the format string , that argument is sent the message description
  • In objective-C an array does not actually contain the objects that belong to it; instead it holds a pointer to each object. (references). This means primitives and C structures cannot be added to an array. 
  • A single array can contain objects of different types. 
  • If you need to add "holes" to an array, you must use NSNull
  • Stylish Cocoa Touch programmers always follow the naming conventions (and they are a lot of them).
  • importing a file is the same as including a file in the C, except you are ensured that the file will only be included once. 
  • the designated initializer makes sure that every instance variable of an object is valid. 
  • in the designated initializer, the first thing you always do is call the superclass's designated initializer using super. The last thing you do is return a pointer to the successfully initialized object using self.
  • using initializers as a chain, reduces the chance for error and makes maintaining the code easier.  
  • init methods are always declared to return id.
  • We call it the isa pointer because an object "is a" instance of that class.
  • An instance method uses the - character just before the return type
  • a class method uses the + character
  • Class methods come first, followed by initializers. This is a convention that makes your header files easier to read. 
  • NSInteger is not an object but a type definition for "unsigned long"
  • Class methods should use self in convenience methods  instead of their class name so that a subclass can be sent the same message. 
  • Exceptions are also known as run-time errors.
  • unrecognized selector means the message you are sending isn't implemented by the receiver.  
  • If two classes have the same name is known as a namespace collision
  • Objective-C has no notion of namespaces. Instead, we prefix class names with two or three lettres to keep them distinct. For example, instead of call name Item we use the MMRItem, where MMR is the first letters of my mythical company. 
#source: Big Nerd Ranch Guide  - iOS Programming 3rd edition. 

Δεν υπάρχουν σχόλια:

Δημοσίευση σχολίου