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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:34:54+00:00 2026-06-03T14:34:54+00:00

i have a problem passing a string to another UIViewController and then open this

  • 0

i have a problem passing a string to another UIViewController and then open this UIViewController, this is what i do:

.h

#import <UIKit/UIKit.h>

@interface BroswerViewController : UIViewController

@property (retain, nonatomic) IBOutlet UIWebView *myBrowserView;
@property (nonatomic, retain) NSString * myString;
@end

.m

@implementation BroswerViewController
@synthesize myBrowserView;
@synthesize myString;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
    // Custom initialization

}
return self;
}

- (void)viewWillAppear:(BOOL)animated {

myString = [myString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://mywebsite/%@",myString]];
NSLog(@"%@",url);
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[myBrowserView loadRequest:request];

}

class where i call it:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (!self.myBroserViewController) {
    self.myBroserViewController = [[[BroswerViewController alloc] initWithNibName:@"BroswerViewController" bundle:nil] autorelease];
}

[self.myBroserViewController setMyString:[NSString stringWithString:[stringArray objectAtIndex:indexPath.row]]];
[self.navigationController pushViewController:self.myBroserViewController animated:YES];
}

ok, so i pass a string to the BrowseViewController class, and then open the browseviewcontroller class and open the url with the string i have passed, and the first time work always, then i return back and pass another string and open the view and the second time works random, and the third time never, and i always receive a EXC_BAD_ACCESS on the line

@synthesize myString;

i don’t know what i wrong…

  • 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-03T14:34:56+00:00Added an answer on June 3, 2026 at 2:34 pm

    I would add a couple of pointers to @Phillip Mills answer.

    -On your init you should set myString to nil. This ensures that if it is released before being set somewhere else, it won’t crash. Including if you use the setter which performs a release on it (you can release a nil reference).

    -On your dealloc, you should release myString (unless you are using ARC).

    -When you set it in viewWillAppear, you either need to do:

    self.myString = [self.myString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    

    or

    NSString *temp = myString;
    [myString release];
    myString = [[temp stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] retain];
    

    they both accomplish the same thing. Using self is easier though.

    -Finally, I would use copy instead of retain unless you have a very specific reason to use retain. This ensures something else doesn’t change it on you.

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

Sidebar

Related Questions

I have a problem when passing data in .getJSON. The reason for this is
I have problem with passing an argument to my simple function in jQuery: When
I have a problem with passing variables as reference in PHP. I want to
My problem is similar to Django Passing Custom Form Parameters to Formset Ive have
I am having a problem with views. I have a view and am passing
I have problem passing a variable from a main page containing a user control
In my MVC application I have a problem with passing data from view to
I have a problem(again)...now i want to pass a String from one Activity to
I have this API function: public ResultEnum DoSomeAction(string a, string b, DateTime c, OtherEnum
I am calling this zip_threading class in another class. string a = zip_threading(?,?) but

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.