Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
Node is saved as draft in My Content >> Draft
  • Blocks in ios

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    Comment on it

    ios Block Code

    __block NSString * previousString;
    __block NSString * currentString;
    differentStrings = ^(void){
    
        currentString = [self getString];
        NSLog(@"%@", currentString); // not printing anything on console
    
        if (![currentString isEqualToString:previousString])
       {
          previousString = currentString;
            return YES;
        }
     else 
     {      return NO;
       }
    };
    
    

    differentStrings is a variable pointing to the block.Thus, when you do this:

    if (differentStrings)

    Remember: differentStrings is a block variable, not a BOOL variable. It contains a block (a function, if you will), which when called will return a bool. Thus, in order to actually run the block, you need to call it. Like this:

    differentStrings();

    or, in your case:

    if (differentStrings())
     {
        NSLog (@"strings are different");
     }

    Using a block to find matching First string to previous string Different Strings is an instance variable. the NSString class also has two methods with block parameters whose names begin with enumerate: enumerateSubstringsInRange:options:usingBlock: and enumerateLinesUsingBlock:. The first method enumerates a string by a text unit of a specified granularity (line, paragraph, word, sentence, and so on); the second method enumerates it by line only.

    iphone

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: