Top 10 reads of July 2015

These are our Top 10 reads of July 2015.

  • How to match strings using wildcards in C# and VB.NET
  • IsSmallerThan generic extension method for C# and VB.NET
  • How to prevent your IOS app from going into sleeping mode using Objective-C
  • How to convert Color to Hex and Hex to Color using C# and VB.NET
  • How to read a embedded resource to String in C# and VB.NET
  • How to convert a Securestring to String using C# and VB.NET
  • How to change the encoding of a String using C# and VB.NET
  • How to get focusedrow cell value using Devexpress XtraGrid in C# and VB.NET
  • How to get the selected row index in Devexpress Xtragrid Control using C# and VB.NET
  • thanks to all visitors, bookmark us, share us, talk about us, Follow us!, Like us! let’s grow bigger! You can even participate in our Github Projects!

    Please rate this snippet

    How to reload a ViewController in IOS using Objective-C

    To reload a UITableViewController in IOS using Objective-C you can simply use the reloadData method of the ViewController.

    //MyTablViewController is a UITableViewController
    [MyTableViewController.tableView reloadData] 
    

    Please rate this snippet

    How to hide the status bar while Splashscreen is Shown in IOS

    To hide the status bar while Splashscreen is Shown in IOS follow these Steps.

  • 1. Open the Info.plist File.
  • 2. Search for the “Status bar is initially hidden” property and set it to checked.
  • if you do not have the “Status bar is initially hidden” property, simply add it by selecting the last line in the File and then click the plus button on the right end of the line.

    To show the status bar you can use this snippet.

    [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone]; //UIStatusBarAnimationNone, UIStatusBarAnimationFade or UIStatusBarAnimationSlide
    

    Please rate this snippet

    How to use substring in IOS using Objective-C

    To use substring in IOS using Objective-C you can use the snippet below.

    Sample Objective-C

    NSString *myString = @"http://codesnippets.fesslersoft.de";
    NSString *myNewString = [myString substringFromIndex:7]; //myNewString will be "codesnippets.fesslersoft.de"
    

    Please rate this snippet

    How to autosize UILabel to Textsize in IOS using Objective-C

    labelTest.text = @"This is my Teststring.This is my Teststring.This is my Teststring.This is my Teststring.This is my Teststring.This is my Teststring.";
    labelTest.numberOfLines = 0;
    [labelTest sizeToFit];
    

    Please rate this snippet

    How to clear notifications in IOS using Objective-C

    To clear notifications in IOS using objective-c you can use the snippet below.

    Sample Objective-C

    //in method: application:didFinishLaunchingWithOptions
    [[UIApplication sharedApplication] setApplicationIconBadgeNumber: 0];
    [[UIApplication sharedApplication] cancelAllLocalNotifications];
    
    //in method: application:didReceiveRemoteNotification
    [[UIApplication sharedApplication] setApplicationIconBadgeNumber: 1]; //we need to to increment first
    [[UIApplication sharedApplication] setApplicationIconBadgeNumber: 0];
    [[UIApplication sharedApplication] cancelAllLocalNotifications];
    

    Please rate this snippet

    How to format a float to 2 decimal places in Objective-C

    To format a float to 2 decimal places in Objective-C you can use the following snippet.

    Sample Objective-C

    NSString* formattedVariable = [NSString stringWithFormat:@"%.02f", myFloatVariable];
    

    Please rate this snippet

    How to convert string to int using Objective-C

    To convert string to int using Objective-C you can use the snippet below.

    Sample Objective-C

    [myString intValue];
    

    or you can do it like this.

    myString.intValue;
    

    Please rate this snippet

    How to Set / Clear and Toggle a single bit in C/C++

    To Set / Clear and Toggle a single bit in C++ see the methods below.

    Setting a bit

    Use the bitwise OR operator (|) to set a bit.

    number |= 1 << x;
    

    Clearing a bit

    Use the bitwise AND operator (&) to clear a bit.

    number &= ~(1 << x);
    

    Toggling a bit

    The XOR operator (^) can be used to toggle a bit.

    number ^= 1 << x;
    

    Source

    Please rate this snippet