NSMutableString *s = [NSMutableString stringWithString: @"123"];
[s appendString: @"456"];
NSString *str = nil;
NSInteger i = str.integerValue;
nil
== 0 but i will have a literal value of 0
and not the void*
value of nil
)NSString str = "test" + " " + "more";
NSPredicate *p2 = [NSPredicate predicateWithBlock:^BOOL(NSString* evaluatedObject, NSDictionary<NSString *,id> * _Nullable bindings) {
return evaluatedObject.intValue % 2 == 0;
}];
NSArray *vals = @[@"1", @"2", @"3"];
NSArray *n2 = [vals filteredArrayUsingPredicate:p2];
NSLog(@"%@", n2.firstObject);
-(float)foo;
#import "NSString+NameHelper.h"
float x = 5.;
for (int x=0; x<100; x++) {
x = x + 1;
}
[self addObserver: self forKeyPath: @"val" options:0 context: nil];
int val = 0;
val = 1.5;
printf("%d", val);
NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys: @"b", @"e", @"a", @"r", nil];
NSMutableDictionary *dict1 = [NSMutableDictionary dictionaryWithCapacity:5];
[dict1 setValue:@"key" forKey:@"value"];
NSData *data = [@"print" dataUsingEncoding:NSASCIIStringEncoding];
NSLog(@"%@", [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]);
+(void)doSomething;
@interface MyClass : NSObject
@property (strong, nonatomic, readonly) NSString *name;
@end
typedef enum { Foo1, Foo2} Foo;
if ([keyPath isInstanceOf:[NSString class]]) {
}
int(^foo)(int);
1. _val = 1;
2. self.val= 100;
float x = 2.0;
int(^foo)(int) = ^(int n1) {
return (int)(n1*x);
};
foo(5);
NSArray *vals = @[@"1", @"2", @"3"];
NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF.intValue > 1"];
NSArray *newVals = [vals filteredArrayUsingPredicate:pred];
-(int)foo:(int)a b:(int)c;
NSError *error;
NSData *data;
id json = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&error];
-(void)testFunc:(NSString**)str;
typedef enum {
thing1,
thing2,
thing3
} Thing;
-(void) enumStuff {
NSLog(@"%d", thing2);
}
int temp = 1==1;
temp
is a keyword.dispatch_async(dispatch_get_main_queue(), ^{
// code
});
NSMutableSet *set1 = [NSMutableSet setWithObjects: @1,@2, @3, @4, @5, nil];
[set1 add0bject:@3];
NSDictionary *d1 = @[@"v1", @4, @"v2", @5.6, @"v3"];
NSlog(@"d1: %@", d1);
val
?@property (nonatomic, readonly) int val;
NSString *val = @"1.23";
BOOL tf = val.boolValue;
@interface TestClass : ThisOne <ThatOne>
NSString *result = [Ftest"
stringByTrimmingCharactersInSet.NSCharacterSet.alphanumericCharacterSet];
MyClass .classObj = [[MyClass allot] init];
[class0bj add0bserver:self forKeyPath:@"name"
options:NSKeyValueObservingOptionNew context:NULL];
[*"true" boolValue];
int loopVal = 0;
for (int i=0; i>loopVal; i--){
i--;
}
NSLog(@"%lu", @"test".length);
NSNumber *numV = [NSNumber numberWithFloat:6.7];
int numVtoInt = numV.intValue;
NSString *val = @"1.23";
NSLog(@"%.04f", val.floatValue);
int r1 = arc4random() % 10;