Loading

Tuesday, November 25, 2014

Get Top View of our app

    UIWindow *topWindow = [[[UIApplication sharedApplication].windows sortedArrayUsingComparator:^NSComparisonResult(UIWindow *win1, UIWindow *win2) {
        return win1.windowLevel - win2.windowLevel;
    }] lastObject];

    UIView *topView = [[topWindow subviews] lastObject];

Tuesday, November 18, 2014

Friday, October 31, 2014

Using an NSString in a switch statement

Define Macros

#define CASE(str)                       if ([__s__ isEqualToString:(str)])
#define SWITCH(s)                       for (NSString *__s__ = (s); ; )
#define DEFAULT


Use

SWITCH (string) {
    CASE (@"AAA") {
        break;
    }
    CASE (@"BBB") {
        break;
    }
    CASE (@"CCC") {
        break;
    }
    DEFAULT {
        break;
    }
 }

Tuesday, October 28, 2014

Ipad stuck on the red battery charging

Fixes these items on your Ipad:
  • Device continually restarts but never displays the Home screen.
  • An update or restore did not complete and the device is no longer recognized in iTunes.
  • Stops responding, showing the Apple logo with no progress bar or a stopped progress bar, for over ten minutes.
Here’s what you’ll need to do to get your Ipad into DFU mode:
  • Plug the iPad into your computer
  • Launch iTunes
  • Hold down the Power button and the Home button at the same time
  • Keep holding both of these buttons for 10 seconds
  • After 10 seconds pass, release the Power button but continue to hold the Home button for another 3-5 seconds
  • When in DFU mode, your iPad screen will stay completely black. If you see an Apple logo or otherwise you did not enter DFU mode
  • iTunes will notify you that it has detected a device in recovery mode
  • Once in DFU mode the Itunes firmware modifying app will take over, follow those instructions
What is Ipad DFU mode?
DFU stands for Device Firmware Update, entering DFU Mode allows you to update or re install your Ipad, Ipod, or other iOS device’s firmware.

Thursday, October 16, 2014

Get Root ViewController of StoryBoard

   

UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];
    
    UINavigationController *NavController = (UINavigationController*)[mainStoryboard instantiateViewControllerWithIdentifier:@"NavController"];

    UIViewController *TheViewController=[[NavController viewControllers] objectAtIndex:0];

You need to specify the controller identifier for your navigation controller in the attributes inspector of the navigation controller

Friday, September 26, 2014

Get primitive type from NSNumber

 const char* type = [theValue objCType];
if (strcmp (type, @encode (NSInteger)) == 0)
{
    //It is NSInteger
}
else if (strcmp (type, @encode (NSUInteger)) == 0)
{
    //It is NSInteger
}
else if (strcmp (type, @encode (int)) == 0)
{
    //It is NSUInteger
}
else if (strcmp (type, @encode (float)) == 0)
{
    //It is float
}
else if (strcmp (type, @encode (double)) == 0)
{
    //It is double
}
else if (strcmp (type, @encode (long)) == 0)
{
    //It is long
}
else if (strcmp (type, @encode (long long)) == 0)
{
    //It is long long
}

Tuesday, August 19, 2014

Singleton Viewcontroller Storyboard

static id s_singleton = nil;
+ (id) alloc {
    if(s_singleton != nil)
        return s_singleton;
    return [super alloc];
}
- (id) initWithCoder:(NSCoder *)aDecoder {
    if(s_singleton != nil)
        return s_singleton;
    self = [super initWithCoder:aDecoder];
    if(self) {
        s_singleton = self;
    }
    return self;

}