Memory management for oc10_ arrays

Source: Internet
Author: User

////main.m//memory management for oc10_ arrays////Created by zhangxueming on 15/6/18.//Copyright (c) 2015 zhangxueming. All rights reserved.//#import<Foundation/Foundation.h>#import "Dog.h"intMainintargcConst Char*argv[]) {@autoreleasepool {Dog*dog1 =[[Dog alloc] init]; Dog*DOG2 =[[Dog alloc] init]; Dog*dog3 =[[Dog alloc] init]; Dog*DOG4 =[[Dog alloc] init]; Dog*dog5 =[[Dog alloc] init]; //adds an object to the array, corresponding to the Retaincount value of the object +1;NSLog (@"dog1 retaincount =%li", Dog1.retaincount); Nsmutablearray*dogs =[[Nsmutablearray alloc] init]; [Dogs Addobject:dog1];//Dogs[0]-->dog1[Dogs Addobject:dog1];//Dogs[1]-->dog1NSLog (@"dog1 retaincount =%li", Dog1.retaincount); [Dogs ADDOBJECT:DOG2];//dogs[2]-->dog2[Dogs Addobject:dog3];        [Dogs ADDOBJECT:DOG4];                [Dogs ADDOBJECT:DOG5];        [Dog1 release];        [DOG2 release];        [Dog3 release];        [Dog4 release];                [Dog5 release]; NSLog (@"dog1 retaincount =%li", Dog1.retaincount); //The array object release is actually the release of each element in a logarithmic array once[Dogs release]; //NSLog (@ "Dog1 Retaincount =%li", dog1.retaincount);            }    return 0;}

Memory management for oc10_ arrays

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.