Not understanding sentence and the importance of @class


#1

Hi Please expalain this sentence to me:

also about @class does it matter if i use @class to declare a super class in a sub class and the other way around?
Like Im using @class BNRPerson in BNREmployee.h file.
Does it with that way?


#2

If you are asking “can I subclass a class by only forward declaring it?” the answer is no.

You can’t forward declare a class and then create a subclass from it:

[code]
// FooBar.h

@class Bar;

@interface FooBar: Bar // Error: we do not know enough about Bar to subclass.

@end
[/code]You must import the header file which contains the declaration of Bar:

// FooBar.h

#import "Bar.h"

@interface FooBar: Bar

@end

However, if you are only declaring an instance variable or a property, a forward declaration in the header file is sufficient:

// FooBar.h

@class Bar;

@interface FooBar: NSObject
{
   Bar *_bar;
}
@end

[quote]Hi Please expalain this sentence to me:

Imagine that you have an array of objects which you can modify by adding objects to it or by removing objects from it.
Now if I ask you to give that array to me, you make a copy of it and pass the copy to me. Therefore if I modify the array I received from you, your array remains intact; or if you change yours, my array remains intact.


#3

Ibex when did I/you modify the array?
Can you tell me which line of code modify the array?


#4

[quote]Can you tell me which line of code modify the array?
[/quote]
An array gets modified when you add an object to it or when you delete an object from it.

Look for a line of code which looks like this:

[someArray addObject:someObject];

See the NSMutableArray Class Reference for other methods that modify an array.