一道 iOS 内存相关的题目
Posted ZCLegendary
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了一道 iOS 内存相关的题目相关的知识,希望对你有一定的参考价值。
运行下面的程序,结果是怎样的?
//
// ViewController.m
// 拖拽按钮
//
// Created by 张闯 on 2018/12/12.
// Copyright © 2018 Rotai. All rights reserved.
//
#import "ViewController.h"
#import "ClassA.h"
@interface ViewController ()
@property (nonatomic, copy) NSString *name;
@property (nonatomic, copy) NSString *age;
@property (nonatomic, copy) NSString *address;
@end
@implementation ViewController
- (void)viewDidLoad
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
for (int i = 0; i < 1000; i++)
dispatch_async(dispatch_get_global_queue(0, 0), ^
self.name = @"123123123123123123";
);
NSLog(@"%@", self.name);
for (int i = 0; i < 1000; i++)
dispatch_async(dispatch_get_global_queue(0, 0), ^
self.age = [NSString stringWithFormat:@"%@", @"1231"];
);
NSLog(@"%@", self.age);
for (int i = 0; i < 1000; i++)
dispatch_async(dispatch_get_global_queue(0, 0), ^
self.address = [NSString stringWithFormat:@"%@", @"asdfsdfasdfadfadfa"];
);
NSLog(@"%@", self.address);
@end
以上是关于一道 iOS 内存相关的题目的主要内容,如果未能解决你的问题,请参考以下文章