ios - CFType for NSArray and NSMutableArray? -
We are working in a way to make changes in a certain array (and all its fixed components, multiple levels), and It seems that the only way to do this is to walk again through all the levels of the fixed array of arrays and use unstable objects either by using arrayWithArray
or mutableCopy
Used to be.
After doing some research, I learned that CFgetCFType ()
while returning the same value (int19) NSArray
and NSMutableArray
Code> function is used
is the attached sample code
NSArray * array = @ [@ "one", @ "two"]; NSMutableArray * mutableArray = [NSMutableArray arrayWithArray: array]; Int id 1 = CFGTTIPID ((__ Bridge CFTYPRFF) (array)); Ent ID 2 = CFGTTIPID ((__ Bridge CFTYPRF) (MuteErray)); NSLog (@ "Type:% i Type:% i", id1, id2);
Why is it, both types of structure come back to the same CFTypeID
? Does this mean that the variability of NSMutableArray
is CFMutableArrayRef
?
NSArray has a very complex and undocumented behavior. It has some crazy stuff to improve the real-world performance. Makes it High level behavior of
NSArray
and NSMutableArray
is well documented, but these two classes are not really in fact instead you are the example of other classes You receive, what you actually get, will depend on the judicious decisions that will make the structure based on the actual data in the array and how you will use it.
Making copies of an array will not actually copy until you modify it, and still, it can never make copies, it can keep the original array all around and the changes made Can maintain a delta of.
If you should know what is happening, then you should not be using Typical behavior you see can be based on operating system versions at any time and possibly even hardware being implemented on your app. Do not believe how In addition, anytime, sub-class NSArray
instead you should leave the array or maybe NSMutableData
(Tip: NSMutableData is awful when the content is potentially too large to fit in RAM).
NSArray
works in practice, because it is unexpected, rather than rely on documentation. Nothing can be trusted undocumented, especially with the NSArray
which is a special case class. NSArray
instead, create a wrapper class that internally uses NSArray
.
Comments
Post a Comment