标签:style ar io color os sp on log bs
//统计字符串字符个数
NSString *str=@"*******";
NSLog(@"str 的长度为: %i",(int)[str length]);
//判断用户名与密码是否相同,如果相同,输出right
#import <Foundation/Foundation.h>
@interface UserService : NSObject
-(void)sayHello:(NSString *)hello withIsMember:(BOOL(^)(NSString *userName,NSString *password))judge;
@end
#import "UserService.h"
@implementation UserService
-(void)sayHello:(NSString *)hello withIsMember:(BOOL (^)(NSString *, NSString *))judge
{
if (judge(@"Jereh",@"Jereh")) {
NSLog(@"%@",hello);
}
else
{
NSLog(@"NO");
}
}
@end
#import <Foundation/Foundation.h>
#import "UserService.h"
int main(int argc, const char * argv[])
{
@autoreleasepool {
UserService *theUser=[[UserService alloc] init];
[theUser sayHello:@"Right" withIsMember:^(NSString *userName,NSString *password){
if ([userName isEqualToString: password]) {
return YES;
}
else
return NO;
}];
}
return 0;
}
标签:style ar io color os sp on log bs
原文地址:http://blog.csdn.net/ytuzhangziyao/article/details/41971399