Dark Horse Programmer---iOS learning log 12

Source: Internet
Author: User

------<a href= "http://www.itheima.com" target= "blank" >java training, Android training, iOS training,. NET training </a>, look forward to communicating with you! -------

1. Storage details of objects

class to create objects, each object in memory occupies a certain amount of storage space, each object has a separate member variable, all the object common class member method, method in the whole memory only one copy, the class itself in memory occupies a storage space, the method of class exists here.

Example:

#import <Foundation/Foundation.h>

Person.h file

@interface Person:nsobject

{

int _age;

NSString *_name;

}

-(void) run;

@end

PERSON.M file

@implementation person

-(void) run{

NSLog (@ "people running");

}

@end


int main (int argc, const char * argv[]) {
@autoreleasepool {

Person *pe = [person new];

Pe.name = @ "Xue-li";

Pe.age = 18;

NSLog (@ "Name:%@, Age:%d", pe.name,pe.age);

[PE run];

[Person new]; three things to do

1. Apply for memory space

2. Initialize the instantiated variable.

3. Return to the first address of the space

Question 1: Which area of the memory is applied for space?

New when applying space in the heap area of memory (the program dynamically allocates memory space)

Initialized to 0 if the instance variable is the base data type at the time of initialization

If the OC string type is initialized to null

2: Instance variables are saved in the declaration place?

Heap pointer variables are stored in the stack area

Question 3: Where is the object method saved?

Code Area

}
return 0;
}

Dark Horse Programmer---iOS learning log 12

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.