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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:26:16+00:00 2026-05-22T03:26:16+00:00

I just got stuck. I have 2 view controllers one is WatchListViewController and 2nd

  • 0

I just got stuck. I have 2 view controllers one is “WatchListViewController” and 2nd is “QuotesViewController” first of all I am pushing from WatchListViewController to QuotesViewController and my action is written here.

-(IBAction)qoutes
{
    QuotesViewController *nextController = [[QuotesViewController alloc] initWithQoutes:symbolForQoutes :exchangeForQoutes :appDelegate.s :code :exchange:exchangeCodeForQoutes];
    [self.navigationController pushViewController:nextController animated:YES]; 
}

it works perfectly my initWithQoutes method is also working good, then in ViewDidLoad method I am sending some request to server via socket and it gives response and reponse is received in my function that is in WatchListViewController:

void receiveData(CFSocketRef s, CFSocketCallBackType type,  CFDataRef address, const void *data, void *info)
{
    char *buffer = (char *)CFDataGetBytePtr((CFDataRef)data); //getting data from server side in a char type veriable "buffer"
    NSString *result = [NSString stringWithUTF8String:buffer]; // getting data in a string from  my buffer
    if (strstr(buffer, "QRES") != NULL) { //if this is a qoutes response
        splits = [result componentsSeparatedByString:@"|"]; //separating string by "|"
        body = [splits objectAtIndex:1]; // choosing index "1"
        splits = [body componentsSeparatedByString:@","]; // separating by ","
        QuotesViewController *quotesViewController = [[QuotesViewController alloc] init];
        [quotesViewController initWithData:splits];
        return;
    }
}

response is received and it goes to the method initWithData with a parameter array “splits” i receive this array in my initWithData and assign it to my other array (generalArray) now general array is assigned to my tableView but before it reloadData of tableView its control goes back to receiveData and return and come back again to my QuotesViewController and reload table view but at that time my array (generalArray) lost its value & values are not loaded in table view.
plz plz help me i got stuck here.

code of method initWithData:

-(void)initWithData:(NSArray *)_general
{ 
general = [[NSMutableArray alloc] init]; //initializing array that can be accessed out of the class 
for (int i=0; i< [_general count]; i++) { 
[general addObject:[_general objectAtIndex:i]]; } 
NSLog(@"%@", general); [self generalValues]; 
} 
-(void)generalValues{ 

[generalTableView reloadData]; 
}
  • 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-22T03:26:17+00:00Added an answer on May 22, 2026 at 3:26 am

    You are creating a QuotesViewController instance here in your C function as –

    [quotesViewController initWithData:splits];
    

    You are not storing a reference to this controller. It is highly likely that this instance of QuotesViewController has the proper values in generalArray. But since you are not storing it for later use, a reference is lost and a memory leak is created.

    Now, if you go on to create another instance of QuotesViewController, it will not have earlier generalArray data as it is a new instance. Since I do not understand the flow of your program, I find it hard to suggest a proper way to go forward but it would be correct to save either the reference in the function or the array itself. If you save the reference, you can simply push it into the navigation controller of if you save the array, you can pass it in the init method.

    EDIT

    Since you are talking of affecting the same controller, you will need to pass the reference to the function.

    void receiveData(CFSocketRef s, CFSocketCallBackType type,  CFDataRef address, const void *data, void *info, QuotesViewController *controller)
    {
        char *buffer = (char *)CFDataGetBytePtr((CFDataRef)data); //getting data from server side in a char type veriable "buffer"
        NSString *result = [NSString stringWithUTF8String:buffer]; // getting data in a string from  my buffer
        if (strstr(buffer, "QRES") != NULL) { //if this is a qoutes response
            splits = [result componentsSeparatedByString:@"|"]; //separating string by "|"
            body = [splits objectAtIndex:1]; // choosing index "1"
            splits = [body componentsSeparatedByString:@","]; // separating by ","
            [controller initWithData:splits];
            return;
        }
    } 
    

    Hopefully this should do it.

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

Sidebar

Related Questions

I got stuck just with one problem: I don't have even an idea why
I just started learning portlet and got stuck in the first place. I have
I got stuck in here, I have a custom scrollview in a view this
I have got stuck with a question I have just been helped on -
I have just jumped into Objective-C and I got stuck pretty early on. I
I'm currently working on a very short project on Prolog, and just got stuck
Just got a request from my boss for an application I'm working on. Basically
I just got Delphi 2009 and have previously read some articles about modifications that
I just got a dedicated server from a hosting company, and for some reason,
I just got through manually removing the bin\ and obj\ folders from around 30

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.