Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

jnoxx

macrumors 65816
Dec 29, 2010
1,343
0
Aartselaar // Antwerp // Belgium
How u want them to change the URL, quite important, u want an adress bar, or u want a settings screen, where they can touch something, or whatever.
Please explain a bit more, and i might help u out there :)
 

Appzyme

macrumors newbie
Original poster
Mar 29, 2011
6
0
How u want them to change the URL, quite important, u want an adress bar, or u want a settings screen, where they can touch something, or whatever.
Please explain a bit more, and i might help u out there :)

Thanks for the reply jnoxx! I want them to be able to press a button and then be taken to a settings screen where they can then modify the current url. Sure hope you can help.
 

Appzyme

macrumors newbie
Original poster
Mar 29, 2011
6
0
Alright, thanks for the clarification.

So, what exactly are you seeking help for now? Is there some specific piece to your solution that you are seeking advice on? Or what?

I'm not sure how to create the settings view that contains the editable "text region" for the url to the webview and then how to connect this "text region" variable to [NSURL URLWithString:mad:"text region"]
 

jnoxx

macrumors 65816
Dec 29, 2010
1,343
0
Aartselaar // Antwerp // Belgium
Easy/most hack and slash coding like is.
On button, load a new modal view controller, load the text from the textfield into a NSUserDefaults, and allways make the label show the current NSuserDefaults too.
Tadaa :)
And if they press a button, dismiss modal view, and load the view from the user defaults ;)

But they are more cleaner ways of doing this :)
 

Appzyme

macrumors newbie
Original poster
Mar 29, 2011
6
0
Easy/most hack and slash coding like is.
On button, load a new modal view controller, load the text from the textfield into a NSUserDefaults, and allways make the label show the current NSuserDefaults too.
Tadaa :)
And if they press a button, dismiss modal view, and load the view from the user defaults ;)

But they are more cleaner ways of doing this :)

Thanks jnoxx. I'm going to try and decode your suggestion :confused: But what are the cleaner ways to do this?
 
Last edited:

jnoxx

macrumors 65816
Dec 29, 2010
1,343
0
Aartselaar // Antwerp // Belgium
I said, cleaner, not easier ;)

Pop a modal screen, that should be fairly easy to figure out.
Put in a UITextfield, add the UITextField delegate to your H file.
on enter, or whatever, save the .text of the textfield into a string. and share that with your other view controller where u need it.
This is the real good way.
But most "beginning" programmers having trouble in Objective-C with sharing data between viewControllers. That's why i suggested to use the NSuserDefaults hack (just save it into the background kind off).
and then retrieve it in ur website URL thingy. :)
Any more questions?

PS: this doesn't mean you have to do it this way, just inputting here :)
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
You should be aware that Apple has some strict and oddball rules regarding webviews where the user can type in the URL. They require that any app with this feature be listed for age 17+ because it's possible to view p0rn with such an app.

I've never heard of a UI like you describe where the user can choose from among a set of URLs but if the user can type in the URL then this rule may come into effect. If instead you have a set of preset URLs that the user can choose from then maybe the rule won't apply.
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
That's why i suggested to use the NSuserDefaults hack

I wouldn't call using NSUserDefaults a hack. It is just one approach among many to data-persistence and comes with its own pros and cons. For example, one pro is that they provide an easy way to preserve values across runs of the applications and another is that they are backed up when synching with iTunes (so, you should be able to delete an application, restore from backup and the values contained in the user defaults should be restored as well).
 

jnoxx

macrumors 65816
Dec 29, 2010
1,343
0
Aartselaar // Antwerp // Belgium
I wouldn't call using NSUserDefaults a hack. It is just one approach among many to data-persistence and comes with its own pros and cons. For example, one pro is that they provide an easy way to preserve values across runs of the applications and another is that they are backed up when synching with iTunes (so, you should be able to delete an application, restore from backup and the values contained in the user defaults should be restored as well).

Interesting, learned something new today.
About the "hack", well. whatever, you're right x)
I just use it for like 1 integer, but for saving a bunch, I would recommand other ways :)
 

Appzyme

macrumors newbie
Original poster
Mar 29, 2011
6
0
Interesting, learned something new today.
About the "hack", well. whatever, you're right x)
I just use it for like 1 integer, but for saving a bunch, I would recommand other ways :)

Thanks jnoxx and dejo! PhoneyDeveloper I'll keep that in mind for sure.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.