nscopying Questions
3
Solved
I've read the NSCopying docs but I am still very unsure about how to implement what is required.
My class Vendor:
@interface Vendor : NSObject
{
NSString *vendorID;
NSMutableArray *availableCa...
Allan asked 3/11, 2010 at 16:28
7
Solved
I want to have a NSDictionary that maps from UIViews to something else.
However, since UIViews do not implement the NSCopying protocol, I can't use them directly as dictionary keys.
Citizen asked 7/6, 2010 at 19:4
3
Solved
Is there any way to use NSCopying without the returned object being of type Any? It always forces me to cast. This seems strange. I'm copying the object, shouldn't Swift know it's the same type by ...
1
Solved
Since the switch to Swift 3.0, and along with it the change of NSDate to Date, the class no longer conforms to the NSCopying protocol.
In Swift 2, this was valid:
let newDate = oldDate.copy()
B...
2
I'm confused looking at Apple's documentation and reading through Cocoa design patterns. In the Apple documentation for copyWithZone:, it reads:
This method exists so class objects can be used i...
8
Solved
What is the difference between copy and mutableCopy when used on either an NSArray or an NSMutableArray?
This is my understanding; is it correct?
// ** NSArray **
NSArray *myArray_imu = [NSArray ...
Looney asked 4/1, 2010 at 20:56
2
Solved
Using instancetype as a return value of init and related methods is the recommended way to proceed, see the latest clang features. However, what is the best practice w.r.t. the return value of copy...
Swordfish asked 10/10, 2013 at 19:31
1
Solved
I've created a custom class which conforms to NSCopying and NSMutableCopying.
I've added an implementation for -copyWithZone: and -mutableCopyWithZone:, but whenever I call -mutableCopy on my obje...
Elyot asked 12/2, 2013 at 20:22
4
Solved
In my app, I have a NSDictionary whose keys should be instances of a subclass of NSManagedObject.
The problem, however, is that NSManagedObject does not implement the NSCopying protocol which mea...
Copp asked 30/9, 2009 at 11:43
2
Solved
I know that copy creates an immutable copy of an object but i just want to know how copywithzone works and what is the basic difference between copy and copywithzone
Freddiefreddy asked 21/8, 2012 at 5:31
1
Solved
I was going through "Pro. Objective-C Design Patterns for iOS" by Chung and found
_sharedSinglton = [[super allocWithZone: NULL] init];
I looked in Apple's documentation for NSCopying as well, b...
5
Solved
It may be simple question, but why implementing NSCopying protocol in my class, I get zone == nil
- (id)copyWithZone:(NSZone *)zone
{
if (zone == nil)
NSLog(@"why this is allways nil");
(...)
...
Saury asked 28/10, 2011 at 19:52
2
Solved
When implementing this method of NSCopying in a class to enable copy, what is the zone param use ?
If I set a new object, I do not need to alloc it with allocWithZone as an alloc is just enough... ...
Lamm asked 8/1, 2011 at 0:24
1
Solved
I have a small class hierarchy that I'm having trouble implementing copyWithZone: for. I've read the NSCopying documentation, and I can't find the correct answer.
Take two classes: Shape and Squar...
Transom asked 17/12, 2010 at 17:1
3
Solved
I know it's needed if your object will be used as a key in an NSDictionary. Are there any other times like this that NSCopying is required?
If I think I don't need my model objects to conform to N...
Indebtedness asked 4/4, 2010 at 2:15
3
Solved
I might be missing something obvious here, but I'm implementing NSCopying on one of my objects. That object has private instance variables that are not exposed via getters, as they shouldn't be use...
Salamanca asked 2/4, 2010 at 15:10
1
© 2022 - 2024 — McMap. All rights reserved.