1

I'm trying to get the device name and make it visibile on a UILabel but I don't know how (Yes, I'm new on XCode). I know I should use[UIDevice currentDevice] but I don't know where and how to make the name visible.

So, where should I use UIDevice? And how can I make the name visible on a UILabel?

rafiki92
  • 21
  • 2
  • 4
  • What does being new in `xcode` have to do with anything. `xcode` is an IDE you can do your code in a text editor if you want being new in `xcode` has nothing to do with your question are it shows is you don't understand what you are doing. – Popeye Dec 26 '13 at 23:28

1 Answers1

5

Use label.text = [UIDevice currentDevice].name;

Edit: Write it in your .m file. If you want to set it as soon as the view loads, insert the code in viewDidLoad.

Lyndsey Scott
  • 37,080
  • 10
  • 92
  • 128
  • Sorry for this but, where should I write that? .m file or .h file? – rafiki92 Dec 26 '13 at 22:11
  • It should be somewhere in your .m file wherever you need to use or store that information for use. – Anil Dec 26 '13 at 22:19
  • Thanks! And how can I make that visible on a UILabel? – rafiki92 Dec 26 '13 at 22:22
  • Did you create the label in your interface? Or are you creating it programmatically? – Lyndsey Scott Dec 26 '13 at 22:27
  • 1
    @rafaelsamanez99 clearly you are new at this. Not knowing to put this in the implementation file .m says to me you need to go away and learn by doing some tutorials, reading some books and then coming back and try what you are doing in a few months. – Popeye Dec 26 '13 at 23:26
  • Look @Popeye, this xcode project is for testing only and that's why I'm asking; because I want to learn and I think the best way to learn is making errors and asking how to do something if you don't know how to. So please, avoid making comments like you just did because it's really annoying. And Lyndsey Scott, thanks for your help, I really appreciate it. The Label is in the interface. – rafiki92 Dec 27 '13 at 01:44
  • No problem. If the label is in the interface, then once you connect it to the .h and @synthesize the label in the .m, in the viewDidLoad method of your .m all you need to do is insert the "label.text = [UIDevice currentDevice].name;" code I mentioned above to set the label's text, but replace "label" with your label's actual name. – Lyndsey Scott Dec 27 '13 at 03:00
  • 1
    @rafaelsamanez99 that is not what this site is for. This site is for developers with real problems not trying to learn how to begin programming. That is what tutorials are for use google. And if you don't know the basics of knowing the difference between .h and .m files and what goes in each you are far behind and you will probably find most of your questions will get closed due to **Minimal understanding** when you come and use this site you have to show you know a minimal understanding which is the basics which you clearly don't know. This is why I advice you go learn first you will benefit. – Popeye Dec 27 '13 at 11:12
  • @rafaelsamanez99 I had held back from voting to close but I have joined the other votes to close based on minimal understanding. – Popeye Dec 27 '13 at 11:13
  • @rafaelsamanez99 oh additionally maybe you should take a look at my profile - I know exactly how to do this I choice not to because you have demonstrated no research or attempts at doing this please read http://meta.stackexchange.com/questions/182266/how-much-research-effort-is-expected-of-stack-overflow-users/182380#182380 – Popeye Dec 27 '13 at 11:21