NSMutableArray更改为副本,从而导致父NSMutableArray中的更改(NSMutableArray changes to the copy causing changes in the parent NSMutableArray as well)
我有一个NSMutableArray是我在我的一个视图控制器中使用的委托。
所以在viewDidLoad中,我像这样制作了一个NSMutableArray的可变副本
@implementation ItemsViewController{ AppDelegate *mydelegate; NSMutableArray* allItems; }
在viewDidLoad中
allItems = [mydelegate.array mutableCopy];
现在我在allItems中做出的任何变化MutableArray也会导致我的mydelegate.array发生变化。 难道我做错了什么?
委托中的我的数组也定义如下
@property (nonatomic, strong) NSMutableArray *array;
I have a NSMutableArray is my delegate that I am using in one of my view controllers as well.
So in viewDidLoad I make a mutable copy of my NSMutableArray like this
@implementation ItemsViewController{ AppDelegate *mydelegate; NSMutableArray* allItems; }
In viewDidLoad
allItems = [mydelegate.array mutableCopy];
Now whatever changes I make in my allItems MutableArray also cause changes in my mydelegate.array. Am I doing something wrong?
Also my array in the delegate is defined as follows
@property (nonatomic, strong) NSMutableArray *array;
原文:https://stackoverflow.com/questions/19785427
满意答案
分区外连接可以帮助填写日历数据。 它类似于交叉连接,但对于非平凡的表大小可能表现更好。
交叉连接将连接集合A中的每一行与集合B中的每一行。
分区外连接将连接集合A中的每一行与集合B中的每个已定义子集。
以下示例仅根据您提供的计划数据生成日期范围。 因此,第14和第15不会出现,但这很容易修复。
with schedules as ( --Schedule data. select 'bottle washer' position, 'Fred' name, date '2013-01-02' startdate, date '2013-01-05' enddate from dual union all select 'bottle washer' position, 'Barney' name, date '2013-01-04' startdate, date '2013-01-07' enddate from dual union all select 'bottle washer' position, 'Betty' name, date '2013-01-10' startdate, null enddate from dual union all select 'bottle washer' position, 'Wilma' name, date '2013-01-12' startdate, date '2013-01-13' enddate from dual union all select 'cook' position, 'Bilbo' name, date '2013-01-01' startdate, date '2013-01-03' enddate from dual union all select 'cook' position, 'Frodo' name, date '2013-01-05' startdate, date '2013-01-08' enddate from dual union all select 'cook' position, 'Bilbo' name, date '2013-01-07' startdate, null enddate from dual ), dates as ( --Date range, based on schedule data. select first_startdate + level - 1 the_date from ( select min(startdate) first_startdate ,(max(enddate) - min(startdate))+1 date_diff from schedules ) connect by level <= date_diff ) --Count of staff working per position, per day. select position, the_date, count(schedules.startdate) staffing from dates left join schedules partition by (position) on dates.the_date between schedules.startdate and nvl(schedules.enddate, date '9999-12-31') group by position, the_date order by position, the_date;
A partition outer join can help fill in calendar data. It is similar to a cross join but may perform much better with non-trivial table sizes.
A cross join will join every row in set A with every row in set B.
A partition outer join will join every row in set A with every defined subset in set B.
The example below generates the date range only based on the schedule data you provided. Therefore the 14th and 15th do not show up, but that can be easy to fix.
with schedules as ( --Schedule data. select 'bottle washer' position, 'Fred' name, date '2013-01-02' startdate, date '2013-01-05' enddate from dual union all select 'bottle washer' position, 'Barney' name, date '2013-01-04' startdate, date '2013-01-07' enddate from dual union all select 'bottle washer' position, 'Betty' name, date '2013-01-10' startdate, null enddate from dual union all select 'bottle washer' position, 'Wilma' name, date '2013-01-12' startdate, date '2013-01-13' enddate from dual union all select 'cook' position, 'Bilbo' name, date '2013-01-01' startdate, date '2013-01-03' enddate from dual union all select 'cook' position, 'Frodo' name, date '2013-01-05' startdate, date '2013-01-08' enddate from dual union all select 'cook' position, 'Bilbo' name, date '2013-01-07' startdate, null enddate from dual ), dates as ( --Date range, based on schedule data. select first_startdate + level - 1 the_date from ( select min(startdate) first_startdate ,(max(enddate) - min(startdate))+1 date_diff from schedules ) connect by level <= date_diff ) --Count of staff working per position, per day. select position, the_date, count(schedules.startdate) staffing from dates left join schedules partition by (position) on dates.the_date between schedules.startdate and nvl(schedules.enddate, date '9999-12-31') group by position, the_date order by position, the_date;
相关问答
更多在SQL中获取日期范围(Get Date Ranges in SQL)
如何使用Oracle SQL选择不同的日期范围(How to select distinct date ranges with Oracle SQL)
如何编写带有2个日期范围的sql子查询(how to write sql subquery with 2 date ranges)
这在SQL中是什么样的方法,它确实存在?(What kind of approach is this in SQL, it actually exists? Is it viable/good pratice?)
是否有一个很好的SQL方法来汇总带有日期范围块作为输入的表?(Is there a good SQL approach for summarizing a table with blocks of date ranges as input?)
总结同一SQL表上的两个条件(Summarizing two conditions on the same SQL table)
SQL - 总结每月销售数据(SQL - Summarizing Monthly Sales Data)
SQL:在每个成员的多个开始和结束日期范围内识别不同的处理块(SQL: Identify distinct blocks of treatment over multiple start and end date ranges for each member)
相关文章
更多CentOS 6.3 更改yum源,改为163源
更改我的网页默认的暴风影音播放器
eclipse的默认(打开)编辑器的更改
HDFS的副本存放策略
android 随手记 仿微信的popwindow
Java泛型父类取得子类的泛型参数T的Class类型
关于继承和static的小问题
关于子类构造器中调用父类构造器的问题
如何向一个页面中的两个iframe传值
spring 4.2已经不支持SimpleJdbcDaoSupport ,改用JdbcDaoSupport
最新问答
更多获取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),本站将尽快处理。谢谢合作!