Encoding the special charecters of a NSString in Objective-c

NSString *unescaped = @"http://www";
NSString *escapedString = (NSString *)CFURLCreateStringByAddingPercentEscapes(
    NULL,
   (CFStringRef)unescaped,
    NULL,
    CFSTR("!*'();:@&=+$,/?%#[]"),
    kCFStringEncodingUTF8);

NSLog(@"escapedString: %@",escapedString);

NSLog output:

escapedString: http%3A%2F%2Fwww

Under ARC one alternative is:

NSString *escapedString = (NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(
    NULL,
   (__bridge CFStringRef) unescaped,
    NULL,
    CFSTR("!*'();:@&=+$,/?%#[]"),
    kCFStringEncodingUTF8));
Advertisements

Ad Mob code in ios

 
    bannerView = [[GADBannerView alloc]
                  initWithFrame:CGRectMake(0, 335, 320, 35)];

                                  (or)

    AbMob = [[GADBannerView alloc]
      initWithFrame:CGRectMake(0.0,
                      self.view.frame.size.height – GAD_SIZE_300x250.height,GAD_SIZE_320x50.width,GAD_SIZE_320x50.height)];
    
    
    bannerView.adUnitID = @”your admob id”;
    bannerView.rootViewController = self;
    [self.view addSubview:bannerView];
    
    
    GADRequest *r = [[GADRequest alloc] init];

//keep testing =Yes if the ad is in testing phase and while uplaoding to appstore remove this line
    r.testing = YES;
    [bannerView loadRequest:r];
    

The frameworks need to be included for admobs are

  • StoreKit
  • AudioToolbox
  • MessageUI
  • SystemConfiguration
  • CoreGraphics
  • AdSupport

and do not forget if you are using the admob version> 6.1 add -ObjC to Otherlinker flags in build settings