Xcode connection

Joined
Jun 13, 2012
Messages
2
Reaction score
0
Points
1
Hi.

I need to make a connection between a text field and the URL of a web browser.

The url has the structure: "?=xxxx". xxxx varies depending on the user.

In the application, you have to put your number (eg. 432) in a text field and then in another section, to access a URL from the application, that URL needs to be changed by "?=432" (for access to your web profile).

Is it possible to do this? If so, can anyone help me?

Thank you very much everyone.
 
Joined
Jun 25, 2005
Messages
3,231
Reaction score
112
Points
63
Location
On the road
Your Mac's Specs
2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid
The following code assumes you are using ARC. For manual referencing counting, refer to the docs.

Code:
- (IBAction) mytextfieldAction: (id) sender
{
NSString * tfString = sender.text; // <-- Assumes sender is a UITextField.
NSString * firstpartofurl = @"http://www.domain.com/?=";
NSString * urlStr = [NSString stringWithFormat: @"%@%@", firstpartofurl, tfString];
NSURL * myURL = [NSURL URLWithString: urlStr]; // Extra credit.
// do something with the urlStr or myURL. To live beyond the scope of the method, use alloc and instance methods.
}
 
OP
A
Joined
Jun 13, 2012
Messages
2
Reaction score
0
Points
1
Thanks for your help xstep.

Is there a tutorial for beginners?

I am new to programming IOS and good with your code I've got to do is declare a UITextField in Viewcontroller.h and put the code on Viewcontroller.m. In the part of "// do something with the urlStr or myURL. To live beyond the scope of the method, use alloc and instance methods." I do not know what to do.
 
Joined
Jun 25, 2005
Messages
3,231
Reaction score
112
Points
63
Location
On the road
Your Mac's Specs
2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid
Not knowing what scope is says that you are new to programming, not just iOS programming. I suggest you buy one of the highly rated beginners books. If you can't afford a book, check your public library.

Apple has The Objective-C Programming Language: Introduction online. You can download the PDF via the PDF button link on the top right side of the window that appears. You may be better off with a introduction book at first. Also learn how to read the documentation.

Scope refers to the accessibility and life of a variable within a block of code. None of the variables in my sample are accessible outside of that method I created them in and will not (or should not) survive once the method has exited. The details are only slightly deeper than this.

Don't be discouraged, it takes time to absorb programming knowledge.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top