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

  • Home
  • SEARCH
  • 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 8123037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:02:09+00:00 2026-06-06T06:02:09+00:00

I have an NSMutableArray of names. I want the pass the data (selected name)

  • 0

I have an NSMutableArray of names. I want the pass the data (selected name) inside of NSMutableArray as text to another view’s label.

FriendsController.m:

- (void)viewDidLoad {
    [super viewDidLoad];
    arrayOfNames=[[NSMutableArray alloc] init];
    arrayOfIDs=[[NSMutableArray alloc] init];
    userName=[[NSString alloc] init];
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    long long fbid = [[arrayOfIDs objectAtIndex:indexPath.row]longLongValue];
    NSString *user=[NSString stringWithFormat:@"%llu/picture",fbid];
    [facebook requestWithGraphPath:user andDelegate:self];

    userName=[NSString stringWithFormat:@"%@",[arrayOfNames objectAtIndex:indexPath.row]];
    FriendDetail *profileDetailName = [[FriendDetail alloc] initWithNibName: @"FriendDetail" bundle: nil];

    profileDetailName.nameString=userName;

    [profileDetailName release];
}

- (void)request:(FBRequest *)request didLoad:(id)result  {
    if ([result isKindOfClass:[NSData class]]) {
        transferImage = [[UIImage alloc] initWithData: result];
        FriendDetail *profileDetailPicture = [[FriendDetail alloc] initWithNibName: @"FriendDetail" bundle: nil];

        [profileDetailPicture view];
        profileDetailPicture.profileImage.image= transferImage;

        profileDetailPicture.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
        [self presentModalViewController:profileDetailPicture animated:YES];

        [profileDetailPicture release];
    }   
} 

In FriendDetail.h

NSString nameString;
IBOutlet UILabel *profileName;
@property (nonatomic, retain) UILabel *profileName;
@property (nonatomic, retain) NSString *nameString;

In FriendDetail.m

- (void)viewDidLoad
{
    [super viewDidLoad];
    profileName.text=nameString;
}

nameString in second controller(FriendDetail) returns nil. When i set a breakpoint in firstcontroller I see the string inside of nameString is correct but after that it returns to nil somehow.

———————–EDIT—————————————-

According to answers I have improved my code little bit
FriendsController.h

 FriendDetail *friendController;
@property (strong, nonatomic) FriendDetail *friendController;

FriendsController.m

- (void)viewDidLoad
{
    [super viewDidLoad];
    arrayOfNames=[[NSMutableArray alloc] init];
    arrayOfIDs=[[NSMutableArray alloc] init];
    arrayOfThumbnails=[[NSMutableArray alloc] init];
    userName=[[NSString alloc] init];

    friendController= [[FriendDetail alloc] initWithNibName: @"FriendDetail" bundle: nil];
}

-(void)request:(FBRequest *)request didLoad:(id)result{
    if ([result isKindOfClass:[NSData class]])
    {
        transferImage = [[UIImage alloc] initWithData: result];
        friendController.nameString=userName;

        [friendController view];
        friendController.profileImage.image= transferImage;


       friendController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
        [self presentModalViewController:friendController animated:YES];
    }
   //this is how i take facebook friends list
         if ([result isKindOfClass:[NSDictionary class]]){
             items = [[(NSDictionary *)result objectForKey:@"data"]retain];
             for (int i=0; i<[items count]; i++) {
            NSDictionary *friend = [items objectAtIndex:i];
            long long fbid = [[friend objectForKey:@"id"]longLongValue];
            NSString *name = [friend objectForKey:@"name"];
            NSLog(@"id: %lld - Name: %@", fbid, name);
            [arrayOfNames addObject:[NSString stringWithFormat:@"%@", name]];
            [arrayOfIDs addObject:[NSNumber numberWithLongLong:fbid]];

        }
    }
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

    long long fbid = [[arrayOfIDs objectAtIndex:indexPath.row]longLongValue];
    NSString *user=[NSString stringWithFormat:@"%llu/picture",fbid];

    userName=[NSString stringWithFormat:@"%@",[arrayOfNames objectAtIndex:indexPath.row]];

    [facebook requestWithGraphPath:user andDelegate:self]; 
    [username retain]
}

Now when i select row first time it sends name. When i come back to tableview and select another name it shows the old name.

If I delete [username retain] in didSelectRowAtIndexPath: it still sends nil to nameString

when I set break point at didSelectRowAtIndexPath: at line `

userName=[NSString stringWithFormat:@"%@",[arrayOfNames objectAtIndex:indexPath.row]]`

I can see userName = @"Adam Dart" which is correct

in my second breakpoint at line friendController.nameString=userName; I see that nameString =nil and userName = Variable is not CFString

ARC is set to NO

  • 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-06T06:02:11+00:00Added an answer on June 6, 2026 at 6:02 am

    The value is nil because you did not pass the value in request:didLoad: function.

    In function didSelectRowAtIndexPath, You create a local instance of another ViewController and set the value of nameString, but you did not present the view and release the ViewController immediately. You actually do nothing in these few lines of code:

    FriendDetail *profileDetailName = [[FriendDetail alloc] initWithNibName: @"FriendDetail" bundle: nil];
    profileDetailName.nameString = userName;
    [profileDetailName release];
    

    In function request:didLoad:, again you create a local instance of another ViewController with image. But this instance is only local to this function, which means no relation to the one created in didSelectRowAtIndexPath.

    What you need to do is, remember the name of clicked row first in didSelectRowAtIndexPath, here you dont have to create the ViewController instance. When the request finish, set both the image and name to the controller and then present it. But you should avoid user from clicking different rows at the same time, because you don’t know when the request finish.

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

Sidebar

Related Questions

I have NSMutableArray* names , which contains NSStrings. I want to sort the array
All. I have a NSMutableArray , which name is dummyPerson. And it's element is
I have an NSMutableArray which has five objects in it. I want to insert
I have a NSMutableArray called putNumberUsed. It contains the following objects @blah1,@blah2,@blah3,@blah4. I want
I have this array of names (listedName) that I want to filter out and
I have NSMutableArray with different objects in it of different classes. Now I want
I have an NSMutableArray of objects. Each object has a property called Name. I
I have created NSMutale Array in HeroListViewController . I want use it in another
I have three NSMutableArray containing names that are added to the lists according to
I want to pass an NSString to a method and have that particular NSString

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.