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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:41:13+00:00 2026-06-03T06:41:13+00:00

i have one array this array contain Question Objects so here i need to

  • 0

i have one array this array contain Question Objects so here i need to change the positions for array

Question *que=[[Question alloc]init];

que=[myarray objectAtIndex:1];

Question *que1=[[Question alloc]init];
que1=[myarray objectAtIndex:2];

here i need to inter change objects each other some 

[que1 setValue: que.name forKey:@"Name"];

[myarray relplaceObjectAtIndex:2 withObject:que1];

is it right way to set value same objectValues

Please guide me hoe can inter change value.

Thanks for 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-03T06:41:14+00:00Added an answer on June 3, 2026 at 6:41 am

    There are significant issues with your code here:

    1. This statement:

      Question *que = [[Question alloc] init];
      

      Allocates a new Question instance and assigns it to the variable que. When you do:

      que = [myarray objectAtIndex:1];
      

      You are overwriting the Question instance that you just allocated, effectively leaking memory (because you never released it). This won’t be a problem if you are using ARC but nevertheless it is something to be mindful of because with or without ARC it is pointless. You did this twice, once for que and once for que1. Since you don’t actually need to allocate and initialise a new Question instance, you can just do:

      Question *que = [myarray objectAtIndex:1];
      
    2. You obtain a reference to a Question object and assign it to que1. Then you mutate it and want to put it back into the array. This is pointless because the array already holds a reference to the same Question instance that you obtained with objectAtIndex:.

    3. You haven’t really explained what you are trying to do. Your entire code basically boils down to:

      [[[myarray objectAtIndex:2] setValue:[[myarray objectAtIndex:1] name] forKey:@"Name"]; 
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a for loop that loops over one array... for i=1:length(myArray) In this
how i can duplicate one element from array: for example, i have this array:
I have converted an array to object data like this: <?php $myobject->data = (object)Array('zero','one','two');
I have two arrays the first one has this structure Parameter Keys array array
I often have the need to search a javascript array that contains objects. I
I have this array: $methodsOutput = array(MidUpperArmMuscleArea,ArmSpan_HeightEstimation,BMIBeforePregnancy, PregnancyTotalWeightGain,PregnancyWeeklyWeightGain,MS_CurrentBMI_BMIPregnancyWeeks, PregnancyDueDate,PregnancyWeeks,WeightEstimation,WHO_BMI_2000_IdealBMI, WHO_BMI_2000_IdealWeight,WHO_HeightAge_2006_IdealHeight,WHO_WeightAge_2006_IdealWeight); and for each one
I have one array. I want that array to retain its value between function
I want to implement singleten design pattern in iphone code I have one array.
I have one main array which is the returned data from a MySQL query
i have one php file which process adding of record in Database fro array.

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.