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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:21:30+00:00 2026-05-13T16:21:30+00:00

It might be that the problem is straight forward but I don’t get my

  • 0

It might be that the problem is straight forward but I don’t get my head around it.

I have the following iPhone code

for(int x = 0 ; x < [allFriends count] ; x++)   
{
    Friend *f = [[Friend alloc] init];          
    f = [allFriends objectAtIndex:x];

    if([uid isEqualToString:[f uid]])
    {                                           
        [f AddAlbum:album];
        [allFriends replaceObjectAtIndex:x withObject:f];
     }                              
}

It doesn’t matter where I call [f release] the app always crashes. Why? (BTW the loop runs a few thousand times)

Is there a more efficient way to do it?

I think I provided enough code, let me know if not!

Thanks heaps for your help!

  • 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-05-13T16:21:31+00:00Added an answer on May 13, 2026 at 4:21 pm

    I think your code has some serious problems:

    1. Why are you allocating a new Friend if you’re going to immediately leak it?
    2. Why replace an object in an array with the same object?

    I think you can replace your code with this loop:

    for (Friend *f in allFriends)
    {
        if([uid isEqualToString:[f uid]])
        {
            [f AddAlbum:album];
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a (big) problem that all of you that work with Webforms might
I'm concerned that this might be working on an NP-Complete problem. I'm hoping someone
I have a text file that might contain thousands and thousands of numbers(0-9 -->
I have a json property that might be null, and I'd prefer to keep
I have a query that might be executed by several users consecutively. I'm scared
I have double (or float) variables that might be empty, as in holding no
im planning to create a movie file that might have over 16,000 frames?i know
As you all might know that the MIPS instruction set supports clz (count leading
The major difference between a thing that might go wrong and a thing that
I am going to ask a question that might sound weird. Is there a

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.