---
title: "IOS数组、字典新写法——@[]、@{}"
author: "lichangjielong"
date: "2014-02-13T15:22:47Z"
tags: ["Objective-C"]
categories: ["移动开发"]
slug: "ios"
draft: false
lastmod: "2014-05-22T17:22:43Z"
id: 2017016
url: "https://lichangjielong.iteye.com/blog/2017016"
---

苹果给objective-C一种新写法

比如
NSNumber * number = [NSNumber numberWithInt:1];
NSArray * array = [NSArray arrayWithObjects:@"one", @"two", nil];
NSDictionary * dict = [NSDictionary dictionaryWithObjectsAndKeys:@"value1", @"key1", @"value2", @"key2", nil];


可以用
NSNumber * number = @1; 
NSArray * array = @[@"one", @"two"];
NSDictionary * dict = @{@"key1":@"value1", @"key2":@"value2"};


NSMutableArray *m_array = [@[] mutableCopy]; 
NSMutableDictionary *m_dict = [@{} mutableCopy];
