Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8385949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:47:41+00:00 2026-06-09T17:47:41+00:00

My classes implement NSCopying like this: @implementation MyClass – (id) copyWithZone: (NSZone *) zone

  • 0

My classes implement NSCopying like this:

@implementation MyClass

- (id) copyWithZone: (NSZone *) zone {
    MyClass *copy = [[MyClass allocWithZone: zone] init];

    // Copy instance variables

    return copy;
}

@end

That means the copy is allocated in the required memory zone. In case the object contains instance variables that need to be copied, too, e.g. mutable arrays, should I use their copyWithZone: message and pass the zone along, instead of just calling copy?

Additionally, if there are instance variables that I want to instantiate directly instead of copying an object, will I have to allocate those by using the allocWithZone: class method?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T17:47:43+00:00Added an answer on June 9, 2026 at 5:47 pm

    Zone is obsolete – there’s nothing special to do with it. If you copy your ivars also, you can safely ignore it and just call copy on them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In classes that implement INotifyPropertyChanged I often see this pattern : public string FirstName
Let's suppose I have an interface named Controller. Several classes implement this interface and
I have two classes which look like this in barebones form: @interface GraphNode {
Many GDI+ classes implement IDisposable, but I'm not sure when I should call Dispose.
Classes that implement IEnumerable and provide a public void Add(/* args */) function can
I know that classes can implement various special methods, such as __iter__ , __setitem__
I need to implement classes to support a custom event capable of passing varying
I have a class that instantiates two classes which implement interfaces. I want one
I'm getting started in developing web services using JAX-WS. I'm trying to implement classes
If I have two classes that both implement an interface, but also inherit, do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.