Q:

Accesing base url from constant class

I have created a class "AppConstant" and defined a global constant for "baseURL" like this. 
  APPCostant.h 
#import <Foundation/Foundation.h>

extern NSString * const appBaseUrl;

@interface APPConstant : NSObject
@end

`  AppConstant.m 
#import "APPConstant.h"

@implementation APPConstant

/** defining base url of server **/
NSString *const AppbaseURL = @"http://www.exapmle.com/";

@end

Now I have imported AppConstant.h in my class where I want to use the base url, and trying to built my url like below, but I am getting the compile-time error.  
Undefined symbols for architecture x86_64:
  "_appBaseUrl", referenced from:
      -[KKSearchViewController searchRequest] in KKSearchViewController.o
 NSURL *url =[NSURL URLWithString:@"search" relativeToURL:[NSURL URLWithString:appBaseUrl]];

I am not sure, whats wrong here. What I want to achieve is little bit cleaner and reusable code, So that I don't have to change the url in every class. 

A:

There are a couple of ways you could achieve what you are after and, unfortunately, you have kind of mixed up both approaches.
The first approach is a global variable.  The second is a class property.
In your .h file you have a global variable, while in your .m file you (kind of) have a class property.
If you want to use the global variable approach, simply remove the @implementation from your .m file:
AppConstant.m
 #import "AppConstant.h"

 NSString * const appBaseUrl = @"http://someserver.com";

You can then simply refer to appBaseUrl as you do in your URLWithString call.
The second approach is to use a class level property.  Unfortunately Objective-C doesn't have class level properties, so you have to declare a class level function that returns your required value.  You can, however, refer to 0 argument methods in Objective C using the . accessor, so it looks like a class level property.
AppConstant.h
#import <Foundation/Foundation.h>

@interface AppConstant : NSObject

+(NSString *)appBaseUrl;

@end

AppConstant.m
#import "AppConstant.h"

@implementation AppConstant

+(NSString *)appBaseUrl {
    return(@"http://someserver.com");
}

@end

In this case you would use AppConstant.appBaseUrl when you wanted the value.

