使用@property和'copy'属性分配NSMutableArray(assign NSMutableArray with @property and 'copy' attribute)
我正在关注官方教程你的第二个iOS应用程序:Storyboard ,它告诉我像这样声明一个属性masterBirdSightingList (只是一个特定的例子,不需要知道上下文):
@property (nonatomic, copy) NSMutableArray *masterBirdSightingList;
请注意,有一个属性副本 。 然后合成这个属性:
@synthesize masterBirdSightingList = _masterBirdSightingList;
接下来有一个让我困惑的init方法:
- (void)initializeDefaultDataList { NSMutableArray *sightingList = [[NSMutableArray alloc] init]; self.masterBirdSightingList = sightingList; [self addBirdSightingWithName:@"Pigeon" location:@"Everywhere"]; }
绝对是为空间分配了sightingList,然后将它分配给masterBirdSightingList属性。 但是,该属性具有复制属性。 这意味着实例变量_masterBirdSightingList将被分配给另一个空间以保存来自sightingList的东西。 为什么? 为什么不直接为属性分配空间,如下所示:
self.masterBirdSightingList = [[NSMutableArray alloc] init];
I'm following an official tutorial Your second iOS App:Storyboard and it told me to declare a property masterBirdSightingList like this(just a specific example and not necessary to know the context) :
@property (nonatomic, copy) NSMutableArray *masterBirdSightingList;
Note that there's an attribute copy. and then synthesize this property :
@synthesize masterBirdSightingList = _masterBirdSightingList;
And next there's one init method which made me confused :
- (void)initializeDefaultDataList { NSMutableArray *sightingList = [[NSMutableArray alloc] init]; self.masterBirdSightingList = sightingList; [self addBirdSightingWithName:@"Pigeon" location:@"Everywhere"]; }
Definitely sightingList is allocated for spaces and then it's assigned to the masterBirdSightingList property. The property has a copy attribute, though. it means the instance variable _masterBirdSightingList would be allocated for another space to preserve stuffs from sightingList. Why? Why not directly allocate space for the property like this :
self.masterBirdSightingList = [[NSMutableArray alloc] init];
原文:https://stackoverflow.com/questions/10724866
满意答案
这显示了每个affyId的平均值:
SELECT affyId, AVG(level) AS average FROM Data GROUP BY affyId
这是每个exptId的平均值:
SELECT exptId, AVG(level) AS average FROM Data GROUP BY exptId
这是每个affyId中每个exptId的平均值:
SELECT affyId, exptId, AVG(level) AS average FROM Data GROUP BY exptId, affyId
This shows the average for every affyId:
SELECT affyId, AVG(level) AS average FROM Data GROUP BY affyId
This the average for every exptId:
SELECT exptId, AVG(level) AS average FROM Data GROUP BY exptId
and this the average for every exptId in every affyId:
SELECT affyId, exptId, AVG(level) AS average FROM Data GROUP BY exptId, affyId
相关问答
更多将返回多个平均值的SQL查询(SQL query that will return multiple averages)
MySQL:同一查询中有两个移动平均线?(MySQL: Two moving averages in the same query?)
MySQL查询平均值(MySQL Query for averages)
MySQL,获取一周中所有日子的平均值(MySQL, get averages for all days of the week)
Sql查询查找过去值的平均值(Sql query to find averages of past values)
MySQL - 获得所有列平均值也具有“总”平均值(MySQL - get all column averages also with a 'total' average)
单个MySQL查询,基于条件的行平均值(Single MySQL query with row averages based on conditions)
Mysql优化查询:尝试获取子查询的平均值(Mysql Optimize Query: Trying to Get Average of Subquery)
MySQL:获取计数和平均值[重复](MySQL: Get Counts and Averages [duplicate])
MySQL查询获取每个月数据的平均值数组(MySQL query to get array of averages of each month's data)
相关文章
更多could not find system property or JNDI
Cannot expose request attribute 'website' because of an existing model object of the same name 的解决方案
mybatis There is no getter for property named 'xx' in 'class java.lang.String
java.lang.IllegalArgumentException: setAttribute: Non-serializable attribute 的解决方案
页面获取ACTION的属性,页面不能弹出JS
移动设备类
Nutch Job failed异常
nutch + solr —— 搭建初探
[032] 微信公众帐号开发教程第8篇-文本消息中使用网页超链接(转)
JavaMelody系统性能监控
最新问答
更多获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
如何通过引用返回对象?(How is returning an object by reference possible?)
矩阵如何存储在内存中?(How are matrices stored in memory?)
每个请求的Java新会话?(Java New Session For Each Request?)
css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
xcode语法颜色编码解释?(xcode syntax color coding explained?)
在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!