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 8883885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:55:38+00:00 2026-06-14T20:55:38+00:00

I have the following problem, because i just have started coding objective-c. I have

  • 0

I have the following problem, because i just have started coding objective-c.

I have some instance with

@interface MyClass
    @property (strong) MySecondClass *first;
    @property (strong) MySecondClass *second;
@end

@implementation MyClass
    @synthesize first = _first;
    @synthesize second = _second;

    /*this is called while initialisation*/
    -(void) initialisation{
        _first = [[MySecondClass alloc] init];
        _second = [[MySecondClass alloc] init];
     }

    /*what i want to do*/
    -(void) swap{
        // second one should be replaced with first one
        _second = _first; 

        // first pointer should be replaced by new instance
        _first = [[MySecondClass alloc] init];
    }

@end

Problem is, that when i call the swap method, the _first still points to the old object so _second will be replaced by same new object.

I already tried copy like follows, but it throws an exception.

 _second = [_first copy];

PS: Im using ARC

Edit

What i really would like to accomplish, would be something like:

 _second = _first
 MySecondClass *tmp = [[MySecondClass alloc] init];
 _first = &tmp;

But this shows compiler error: Implicit conversion of an indirect pointer to an Objective-C pointer to ‘MySecondClass *’ is disallowed with ARC

Thanks in advance.

  • 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-14T20:55:40+00:00Added an answer on June 14, 2026 at 8:55 pm

    What i really would like to accomplish, would be something like:

    _second = _first
    MySecondClass *tmp = [[MySecondClass alloc] init];
    _first = &tmp;
    

    But this shows compiler error: Implicit conversion of an indirect pointer to an Objective-C pointer to ‘MySecondClass *’ is disallowed with ARC

    That’s because the values of _first, _second, and tmp are already pointers, so “&tmp” is a pointer to a pointer—an “indirect pointer” (not especially clear wording on the compiler authors’ part).

    The solution there is to not say &tmp. You just want tmp here.

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

Sidebar

Related Questions

Hi i have following Problem. I write a Mediawiki Extension where i need some
I have the following problem. I am using Reporting Services 2005 to create some
I have the following problem just in the Internet Explorer. The problem is: I
I just have started to program with java rmi and I face the following
I have the following problem: I want to use images for my navigation, because
I have following problem: I have to make a ASP.NET Webapplication with a two-row
I have following problem: I have built a tabbar application with 4 tabs. I
I have following problem, Code: String a=Yeahh, I have no a idea what's happening
I am using GWT/JAVA for development. I have following problem: I want to remove
I have the following problem. I have embedded a map using Google Maps' API.

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.