tags:

views:

47

answers:

1

What is the difference between using the following:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

    NSString *dir = [paths objectAtIndex:0]; 

    NSString *dir2 = paths[0]; // this throws incompatible type exception
+3  A: 
  1. paths is a pointer to instance of NSArray that you are sending the objectAtIndex: message. The receiver returns an id.
  2. paths[0] is the memory address of the beginning of an array in pure C. [] and NSArray are not the same thing.
falconcreek
So, when I use paths[0] what will be the receiver type? Is it some sort of int value which represents the memory address of the beginning of the array.
azamsharp
paths[0] is just a pointer. it is not an object which means it does not have methods. In pure C you have to know what the array contains in order to use it.
falconcreek