1

I am developing an iOS app, this is my first experience in app development. I like to get you peoples suggestions to build the app in a standardize manner. Can anyone tell me what is the best place to put the constant strings?

for now i am using the constants in this way #define __string @"string" is that ok?

Minisha
  • 2,117
  • 2
  • 25
  • 56
  • How many implementation files need to see these constants? – trojanfoe Jan 16 '14 at 15:47
  • Constants are generally written in uppercase, words seperated by underscore(`_`) – Anupdas Jan 16 '14 at 15:48
  • almost 10 to 15 files – Minisha Jan 16 '14 at 15:48
  • If they are only `#define`s then you could put them into a header file, that's `#import`ed from these implementation files. If they require definition somewhere (i.e. `extern NSString * const someString;` etc, and there are many of them then use a header and implementation file. – trojanfoe Jan 16 '14 at 15:49
  • Ok thank you. And what is the best place to do validation? for instance: if i have a form with the fields: name, age etc. And i don't have a save button. when the user transfer from one view controller to another, his details should be saved automatically. I am doing the validation in didFieldEndEditing is that okay? or any other suggestions? – Minisha Jan 16 '14 at 18:46

2 Answers2

1

create constant header file first after define your constant as macro then import to where you want through access your constant

enter image description here

codercat
  • 22,873
  • 9
  • 61
  • 85
0

I put them in the [APP_NAME]-prefix.pch file like this:

#define SERVICE_BASE_URL @"http://url.com"

Rami Enbashi
  • 3,526
  • 1
  • 19
  • 21