Is this the wrong way of doing. Should i use ASIHTTPRequest? Can someone point me in the right direction, that would be nice!
You're close. However, NSURL does not have a method initWithContentsOfURL. You should replace initWithContentsOfURL with initWithString in the above code.
You also need to make sure that the string you pass in does not contain any characters that need to be escaped, like "/", "?", quotes, spaces, "%", ":", etc. If it might, you will need to percent escape it before inserting it into your URL string.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
You're close. However, NSURL does not have a method initWithContentsOfURL. You should replace initWithContentsOfURL with initWithString in the above code.
You also need to make sure that the string you pass in does not contain any characters that need to be escaped, like "/", "?", quotes, spaces, "%", ":", etc. If it might, you will need to percent escape it before inserting it into your URL string.
Thanks for the quick answer. I'm still having some trouble after following your advice. Currently i have this piece of code which takes a value from a textfield and convert it into a string. When i try to put that string in a url, the compiler says that have to many arguments in the method call.
Thanks for the quick answer. I'm still having some trouble after following your advice. Currently i have this piece of code which takes a value from a textfield and convert it into a string. When i try to put that string in a url, the compiler says that have to many arguments in the method call.
I'm guessing that the last line is the one that's throwing an error?
The method initWithString only takes one parameter, and you are passing 2 parameters.
You need to first create an URL string, then pass that string to the initWith string method.
Add a new local variable theURLString. Use stringWithFormat to build theURLString from your URL string, and the number string. Then pass theURLString to the NSURL method initWithString.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
I'm guessing that the last line is the one that's throwing an error?
The method initWithString only takes one parameter, and you are passing 2 parameters.
You need to first create an URL string, then pass that string to the initWith string method.
Add a new local variable theURLString. Use stringWithFormat to build theURLString from your URL string, and the number string. Then pass theURLString to the NSURL method initWithString.