1#import <Foundation/Foundation.h> 2 3#if defined(__APPLE__) 4#if defined(__arm__) || defined(__arm64__) || defined(__aarch64__) 5#define IOS 6#endif 7#endif 8 9#if defined(IOS) 10#import <Foundation/NSGeometry.h> 11#else 12#import <Carbon/Carbon.h> 13#endif 14 15@interface MyClass : NSObject { 16 int i; 17 char c; 18 float f; 19} 20 21- (id)initWithInt:(int)x andFloat:(float)y andChar:(char)z; 22- (int)doIncrementByInt:(int)x; 23 24@end 25 26@interface MyOtherClass : MyClass { 27 int i2; 28 MyClass *backup; 29} 30- (id)initWithInt:(int)x andFloat:(float)y andChar:(char)z andOtherInt:(int)q; 31 32@end 33 34@implementation MyClass 35 36- (id)initWithInt:(int)x andFloat:(float)y andChar:(char)z { 37 self = [super init]; 38 if (self) { 39 self->i = x; 40 self->f = y; 41 self->c = z; 42 } 43 return self; 44} 45 46- (int)doIncrementByInt:(int)x { 47 self->i += x; 48 return self->i; 49} 50 51@end 52 53@implementation MyOtherClass 54 55- (id)initWithInt:(int)x andFloat:(float)y andChar:(char)z andOtherInt:(int)q { 56 self = [super initWithInt:x andFloat:y andChar:z]; 57 if (self) { 58 self->i2 = q; 59 self->backup = [[MyClass alloc] initWithInt:x andFloat:y andChar:z]; 60 } 61 return self; 62} 63 64@end 65 66@interface Atom : NSObject { 67 float mass; 68} 69- (void)setMass:(float)newMass; 70- (float)mass; 71@end 72 73@interface Molecule : NSObject { 74 NSArray *atoms; 75} 76- (void)setAtoms:(NSArray *)newAtoms; 77- (NSArray *)atoms; 78@end 79 80@implementation Atom 81 82- (void)setMass:(float)newMass { 83 mass = newMass; 84} 85- (float)mass { 86 return mass; 87} 88 89@end 90 91@implementation Molecule 92 93- (void)setAtoms:(NSArray *)newAtoms { 94 atoms = newAtoms; 95} 96- (NSArray *)atoms { 97 return atoms; 98} 99@end 100 101@interface My_KVO_Observer : NSObject 102- (void)observeValueForKeyPath:(NSString *)keyPath 103 ofObject:(id)object 104 change:(NSDictionary *)change 105 context:(void *)context; 106- (id)init; 107- (void)dealloc; 108@end 109 110@implementation My_KVO_Observer 111- (void)observeValueForKeyPath:(NSString *)keyPath 112 ofObject:(id)object 113 change:(NSDictionary *)change 114 context:(void *)context { 115 // we do not really care about KVO'ing - do nothing 116 return; 117} 118- (id)init { 119 self = [super init]; 120 return self; 121} 122 123- (void)dealloc { 124 [super dealloc]; 125} 126@end 127 128int main(int argc, const char *argv[]) { 129 130 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 131 132 MyClass *object = [[MyClass alloc] initWithInt:1 andFloat:3.14 andChar:'E']; 133 134 [object doIncrementByInt:3]; 135 136 MyOtherClass *object2 = [[MyOtherClass alloc] initWithInt:2 137 andFloat:6.28 138 andChar:'G' 139 andOtherInt:-1]; 140 141 [object2 doIncrementByInt:3]; 142 143 NSNumber *num1 = [NSNumber numberWithInt:5]; 144 NSNumber *num2 = [NSNumber numberWithFloat:3.14]; 145 NSNumber *num3 = [NSNumber numberWithDouble:3.14]; 146 NSNumber *num4 = [NSNumber numberWithUnsignedLongLong:0xFFFFFFFFFFFFFFFE]; 147 NSNumber *num5 = [NSNumber numberWithChar:'A']; 148 NSNumber *num6 = [NSNumber numberWithUnsignedLongLong:0xFF]; 149 NSNumber *num7 = [NSNumber numberWithLong:0x1E8480]; 150 NSNumber *num8_Y = [NSNumber numberWithBool:YES]; 151 NSNumber *num8_N = [NSNumber numberWithBool:NO]; 152 NSNumber *num9 = [NSNumber numberWithShort:0x1E8480]; 153 NSNumber *num_at1 = @12; 154 NSNumber *num_at2 = @-12; 155 NSNumber *num_at3 = @12.5; 156 NSNumber *num_at4 = @-12.5; 157 158 NSDecimalNumber *decimal_number = 159 [NSDecimalNumber decimalNumberWithMantissa:123456 160 exponent:-10 161 isNegative:NO]; 162 NSDecimalNumber *decimal_number_neg = 163 [NSDecimalNumber decimalNumberWithMantissa:123456 164 exponent:10 165 isNegative:YES]; 166 NSDecimalNumber *decimal_one = [NSDecimalNumber one]; 167 NSDecimalNumber *decimal_zero = [NSDecimalNumber zero]; 168 NSDecimalNumber *decimal_nan = [NSDecimalNumber notANumber]; 169 170 NSString *str0 = [num6 stringValue]; 171 172 NSString *str1 = 173 [NSString stringWithCString:"A rather short ASCII NSString object is here" 174 encoding:NSASCIIStringEncoding]; 175 176 NSString *str2 = [NSString 177 stringWithUTF8String:"A rather short UTF8 NSString object is here"]; 178 179 NSString *str3 = @"A string made with the at sign is here"; 180 181 NSString *str4 = [NSString 182 stringWithFormat:@"This is string number %ld right here", (long)4]; 183 184 NSRect ns_rect_4str = {{1, 1}, {5, 5}}; 185 186 NSString *str5 = NSStringFromRect(ns_rect_4str); 187 188 NSString *str6 = [@"/usr/doc/README.1ST" pathExtension]; 189 190 const unichar myCharacters[] = {0x03C3, 'x', 'x'}; 191 NSString *str7 = [NSString 192 stringWithCharacters:myCharacters 193 length:sizeof myCharacters / sizeof *myCharacters]; 194 195 NSString *str8 = 196 [@"/usr/doc/" 197 @"file." 198 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt" 199 @"ensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime" 200 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt" 201 @"ensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime" 202 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt" 203 @"ensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime" 204 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt" 205 @"ensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime" 206 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt" 207 @"ensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime" 208 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt" 209 @"ensionThisTime" pathExtension]; 210 211 const unichar myOtherCharacters[] = { 212 'a', ' ', 'v', 'e', 'r', 'y', ' ', 'm', 'u', 'c', 'h', ' ', 'b', 'o', 213 'r', 'i', 'n', 'g', ' ', 't', 'a', 's', 'k', ' ', 't', 'o', ' ', 'w', 214 'r', 'i', 't', 'e', ' ', 'a', ' ', 's', 't', 'r', 'i', 'n', 'g', ' ', 215 't', 'h', 'i', 's', ' ', 'w', 'a', 'y', '!', '!', 0x03C3, 0}; 216 NSString *str9 = [NSString stringWithCharacters:myOtherCharacters 217 length:sizeof myOtherCharacters / 218 sizeof *myOtherCharacters]; 219 220 const unichar myNextCharacters[] = {0x03C3, 0x0000}; 221 222 NSString *str10 = [NSString 223 stringWithFormat:@"This is a Unicode string %S number %ld right here", 224 myNextCharacters, (long)4]; 225 226 NSString *str11 = NSStringFromClass([str10 class]); 227 228 NSString *label1 = @"Process Name: "; 229 NSString *label2 = @"Process Id: "; 230 NSString *processName = [[NSProcessInfo processInfo] processName]; 231 NSString *processID = [NSString 232 stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]]; 233 NSString *str12 = [NSString 234 stringWithFormat:@"%@ %@ %@ %@", label1, processName, label2, processID]; 235 236 NSString *strA1 = 237 [NSString stringWithCString:"A rather short ASCII NSString object is here" 238 encoding:NSASCIIStringEncoding]; 239 240 NSString *strA2 = [NSString 241 stringWithUTF8String:"A rather short UTF8 NSString object is here"]; 242 243 NSString *strA3 = @"A string made with the at sign is here"; 244 245 NSString *strA4 = [NSString 246 stringWithFormat:@"This is string number %ld right here", (long)4]; 247 248 NSString *strA5 = NSStringFromRect(ns_rect_4str); 249 250 NSString *strA6 = [@"/usr/doc/README.1ST" pathExtension]; 251 252 NSString *strA7 = [NSString 253 stringWithCharacters:myCharacters 254 length:sizeof myCharacters / sizeof *myCharacters]; 255 256 NSString *strA8 = 257 [@"/usr/doc/" 258 @"file." 259 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt" 260 @"ensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime" 261 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt" 262 @"ensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime" 263 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt" 264 @"ensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime" 265 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt" 266 @"ensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime" 267 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt" 268 @"ensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime" 269 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt" 270 @"ensionThisTime" pathExtension]; 271 272 NSString *strA9 = [NSString stringWithCharacters:myOtherCharacters 273 length:sizeof myOtherCharacters / 274 sizeof *myOtherCharacters]; 275 276 NSString *strA10 = [NSString 277 stringWithFormat:@"This is a Unicode string %S number %ld right here", 278 myNextCharacters, (long)4]; 279 280 NSString *strA11 = NSStringFromClass([str10 class]); 281 282 NSString *strA12 = [NSString 283 stringWithFormat:@"%@ %@ %@ %@", label1, processName, label2, processID]; 284 285 NSString *strB1 = 286 [NSString stringWithCString:"A rather short ASCII NSString object is here" 287 encoding:NSASCIIStringEncoding]; 288 289 NSString *strB2 = [NSString 290 stringWithUTF8String:"A rather short UTF8 NSString object is here"]; 291 292 NSString *strB3 = @"A string made with the at sign is here"; 293 294 NSString *strB4 = [NSString 295 stringWithFormat:@"This is string number %ld right here", (long)4]; 296 297 NSString *strB5 = NSStringFromRect(ns_rect_4str); 298 299 NSString *strB6 = [@"/usr/doc/README.1ST" pathExtension]; 300 301 NSString *strB7 = [NSString 302 stringWithCharacters:myCharacters 303 length:sizeof myCharacters / sizeof *myCharacters]; 304 305 NSString *strB8 = 306 [@"/usr/doc/" 307 @"file." 308 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt" 309 @"ensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime" 310 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt" 311 @"ensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime" 312 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt" 313 @"ensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime" 314 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt" 315 @"ensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime" 316 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt" 317 @"ensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime" 318 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt" 319 @"ensionThisTime" pathExtension]; 320 321 NSString *strB9 = [NSString stringWithCharacters:myOtherCharacters 322 length:sizeof myOtherCharacters / 323 sizeof *myOtherCharacters]; 324 325 NSString *strB10 = [NSString 326 stringWithFormat:@"This is a Unicode string %S number %ld right here", 327 myNextCharacters, (long)4]; 328 329 NSString *strB11 = NSStringFromClass([str10 class]); 330 331 NSString *strB12 = [NSString 332 stringWithFormat:@"%@ %@ %@ %@", label1, processName, label2, processID]; 333 334 NSString *strC11 = NSStringFromClass([str10 class]); 335 336 NSString *strC12 = [NSString 337 stringWithFormat:@"%@ %@ %@ %@", label1, processName, label2, processID]; 338 339 NSString *strC1 = 340 [NSString stringWithCString:"A rather short ASCII NSString object is here" 341 encoding:NSASCIIStringEncoding]; 342 343 NSString *strC2 = [NSString 344 stringWithUTF8String:"A rather short UTF8 NSString object is here"]; 345 346 NSString *strC3 = @"A string made with the at sign is here"; 347 348 NSString *strC4 = [NSString 349 stringWithFormat:@"This is string number %ld right here", (long)4]; 350 351 NSString *strC5 = NSStringFromRect(ns_rect_4str); 352 353 NSString *strC6 = [@"/usr/doc/README.1ST" pathExtension]; 354 355 NSString *strC7 = [NSString 356 stringWithCharacters:myCharacters 357 length:sizeof myCharacters / sizeof *myCharacters]; 358 359 NSString *strC8 = 360 [@"/usr/doc/" 361 @"file." 362 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt" 363 @"ensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime" 364 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt" 365 @"ensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime" 366 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt" 367 @"ensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime" 368 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt" 369 @"ensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime" 370 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt" 371 @"ensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime" 372 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt" 373 @"ensionThisTime" pathExtension]; 374 375 NSString *strC9 = [NSString stringWithCharacters:myOtherCharacters 376 length:sizeof myOtherCharacters / 377 sizeof *myOtherCharacters]; 378 379 NSString *strC10 = [NSString 380 stringWithFormat:@"This is a Unicode string %S number %ld right here", 381 myNextCharacters, (long)4]; 382 383 NSString *strD11 = NSStringFromClass([str10 class]); 384 385 NSString *strD12 = [NSString 386 stringWithFormat:@"%@ %@ %@ %@", label1, processName, label2, processID]; 387 388 NSString *eAcute = [NSString stringWithFormat:@"%C", 0x00E9]; 389 NSString *randomHaziChar = [NSString stringWithFormat:@"%C", 0x9DC5]; 390 NSString *japanese = @"色は匂へど散りぬるを"; 391 NSString *italian = @"L'Italia è una Repubblica democratica, fondata sul " 392 @"lavoro. La sovranità appartiene al popolo, che la " 393 @"esercita nelle forme e nei limiti della Costituzione."; 394 NSString *french = 395 @"Que veut cette horde d'esclaves, De traîtres, de rois conjurés?"; 396 NSString *german = @"Über-Ich und aus den Ansprüchen der sozialen Umwelt"; 397 398 void *data_set[3] = {str1, str2, str3}; 399 400 NSString *hebrew = [NSString stringWithString:@"לילה טוב"]; 401 402 NSArray *newArray = [[NSMutableArray alloc] init]; 403 [newArray addObject:str1]; 404 [newArray addObject:str2]; 405 [newArray addObject:str3]; 406 [newArray addObject:str4]; 407 [newArray addObject:str5]; 408 [newArray addObject:str6]; 409 [newArray addObject:str7]; 410 [newArray addObject:str8]; 411 [newArray addObject:str9]; 412 [newArray addObject:str10]; 413 [newArray addObject:str11]; 414 [newArray addObject:str12]; 415 [newArray addObject:strA1]; 416 [newArray addObject:strA2]; 417 [newArray addObject:strA3]; 418 [newArray addObject:strA4]; 419 [newArray addObject:strA5]; 420 [newArray addObject:strA6]; 421 [newArray addObject:strA7]; 422 [newArray addObject:strA8]; 423 [newArray addObject:strA9]; 424 [newArray addObject:strA10]; 425 [newArray addObject:strA11]; 426 [newArray addObject:strA12]; 427 [newArray addObject:strB1]; 428 [newArray addObject:strB2]; 429 [newArray addObject:strB3]; 430 [newArray addObject:strB4]; 431 [newArray addObject:strB5]; 432 [newArray addObject:strB6]; 433 [newArray addObject:strB7]; 434 [newArray addObject:strB8]; 435 [newArray addObject:strB9]; 436 [newArray addObject:strB10]; 437 [newArray addObject:strB11]; 438 [newArray addObject:strB12]; 439 [newArray addObject:strC1]; 440 [newArray addObject:strC2]; 441 [newArray addObject:strC3]; 442 [newArray addObject:strC4]; 443 [newArray addObject:strC5]; 444 [newArray addObject:strC6]; 445 [newArray addObject:strC7]; 446 [newArray addObject:strC8]; 447 [newArray addObject:strC9]; 448 [newArray addObject:strC10]; 449 [newArray addObject:strC11]; 450 [newArray addObject:strC12]; 451 [newArray addObject:strD11]; 452 [newArray addObject:strD12]; 453 454 NSDictionary *newDictionary = [[NSDictionary alloc] initWithObjects:newArray 455 forKeys:newArray]; 456 NSDictionary *newMutableDictionary = [[NSMutableDictionary alloc] init]; 457 [newMutableDictionary setObject:@"foo" forKey:@"bar0"]; 458 [newMutableDictionary setObject:@"foo" forKey:@"bar1"]; 459 [newMutableDictionary setObject:@"foo" forKey:@"bar2"]; 460 [newMutableDictionary setObject:@"foo" forKey:@"bar3"]; 461 [newMutableDictionary setObject:@"foo" forKey:@"bar4"]; 462 [newMutableDictionary setObject:@"foo" forKey:@"bar5"]; 463 [newMutableDictionary setObject:@"foo" forKey:@"bar6"]; 464 [newMutableDictionary setObject:@"foo" forKey:@"bar7"]; 465 [newMutableDictionary setObject:@"foo" forKey:@"bar8"]; 466 [newMutableDictionary setObject:@"foo" forKey:@"bar9"]; 467 [newMutableDictionary setObject:@"foo" forKey:@"bar10"]; 468 [newMutableDictionary setObject:@"foo" forKey:@"bar11"]; 469 [newMutableDictionary setObject:@"foo" forKey:@"bar12"]; 470 [newMutableDictionary setObject:@"foo" forKey:@"bar13"]; 471 [newMutableDictionary setObject:@"foo" forKey:@"bar14"]; 472 [newMutableDictionary setObject:@"foo" forKey:@"bar15"]; 473 [newMutableDictionary setObject:@"foo" forKey:@"bar16"]; 474 [newMutableDictionary setObject:@"foo" forKey:@"bar17"]; 475 [newMutableDictionary setObject:@"foo" forKey:@"bar18"]; 476 [newMutableDictionary setObject:@"foo" forKey:@"bar19"]; 477 [newMutableDictionary setObject:@"foo" forKey:@"bar20"]; 478 479 CFMutableDictionaryRef newMutableDictionaryRef = CFDictionaryCreateMutableCopy(kCFAllocatorDefault, 0, newMutableDictionary); 480 481 id cfKeys[4] = {@"foo", @"bar", @"baz", @"quux"}; 482 id cfValues[4] = {@"foo", @"bar", @"baz", @"quux"}; 483 NSDictionary *nsDictionary = CFBridgingRelease( 484 CFDictionaryCreate(nil, (void *)cfKeys, (void *)cfValues, 2, nil, nil)); 485 NSDictionary *nscfDictionary = CFBridgingRelease( 486 CFDictionaryCreate(nil, (void *)cfKeys, (void *)cfValues, 4, nil, nil)); 487 CFDictionaryRef cfDictionaryRef = (__bridge CFDictionaryRef)nsDictionary; 488 489 NSAttributedString *attrString = 490 [[NSAttributedString alloc] initWithString:@"hello world from foo" 491 attributes:newDictionary]; 492 [attrString isEqual:nil]; 493 NSAttributedString *mutableAttrString = 494 [[NSMutableAttributedString alloc] initWithString:@"hello world from foo" 495 attributes:newDictionary]; 496 [mutableAttrString isEqual:nil]; 497 498 NSString *mutableString = [[NSMutableString alloc] initWithString:@"foo"]; 499 [mutableString 500 insertString: 501 @"foo said this string needs to be very long so much longer than " 502 @"whatever other string has been seen ever before by anyone of the " 503 @"mankind that of course this is still not long enough given what " 504 @"foo our friend foo our lovely dearly friend foo desired of us so i " 505 @"am adding more stuff here for the sake of it and for the joy of " 506 @"our friend who is named guess what just foo. hence, dear friend " 507 @"foo, stay safe, your string is now long enough to accommodate " 508 @"your testing need and I will make sure that if not we extend it " 509 @"with even more fuzzy random meaningless words pasted one after the " 510 @"other from a long tiresome friday evening spent working in my " 511 @"office. my office mate went home but I am still randomly typing " 512 @"just for the fun of seeing what happens of the length of a Mutable " 513 @"String in Cocoa if it goes beyond one byte.. so be it, dear " 514 atIndex:0]; 515 516 NSString *mutableGetConst = 517 [NSString stringWithCString:[mutableString cString]]; 518 519 [mutableGetConst length]; 520 521 NSData *immutableData = [[NSData alloc] initWithBytes:"HELLO" length:5]; 522 NSData *mutableData = [[NSMutableData alloc] initWithBytes:"NODATA" length:6]; 523 524 // No-copy versions of NSData initializers use NSConcreteData if over 2^16 525 // elements are specified. 526 unsigned concreteLength = 100000; 527 void *zeroes1 = calloc(1, concreteLength); 528 // initWithBytesNoCopy takes ownership of the buffer. 529 NSData *concreteData = [[NSData alloc] initWithBytesNoCopy:zeroes1 530 length:concreteLength]; 531 void *zeroes2 = calloc(1, concreteLength); 532 NSMutableData *concreteMutableData = 533 [[NSMutableData alloc] initWithBytesNoCopy:zeroes2 length:concreteLength]; 534 535 [mutableData appendBytes:"MOREDATA" length:8]; 536 537 [immutableData length]; 538 [mutableData length]; 539 540 NSSet *nsset = [[NSSet alloc] initWithObjects:str1, str2, str3, nil]; 541 NSSet *nsmutableset = 542 [[NSMutableSet alloc] initWithObjects:str1, str2, str3, nil]; 543 [nsmutableset addObject:str4]; 544 NSSet *nscfSet = 545 CFBridgingRelease(CFSetCreate(nil, (void *)cfValues, 2, nil)); 546 CFSetRef cfSetRef = (__bridge CFSetRef)nscfSet; 547 548 CFDataRef data_ref = 549 CFDataCreate(kCFAllocatorDefault, [immutableData bytes], 5); 550 551 CFMutableDataRef mutable_data_ref = 552 CFDataCreateMutable(kCFAllocatorDefault, 8); 553 CFDataAppendBytes(mutable_data_ref, [mutableData bytes], 5); 554 555 CFMutableStringRef mutable_string_ref = CFStringCreateMutable(NULL, 100); 556 CFStringAppend(mutable_string_ref, CFSTR("Wish ya knew")); 557 558 CFStringRef cfstring_ref = CFSTR("HELLO WORLD"); 559 560 CFArrayRef cfarray_ref = CFArrayCreate(NULL, data_set, 3, NULL); 561 CFMutableArrayRef mutable_array_ref = CFArrayCreateMutable(NULL, 16, NULL); 562 563 CFArraySetValueAtIndex(mutable_array_ref, 0, str1); 564 CFArraySetValueAtIndex(mutable_array_ref, 1, str2); 565 CFArraySetValueAtIndex(mutable_array_ref, 2, str3); 566 CFArraySetValueAtIndex(mutable_array_ref, 3, str4); 567 CFArraySetValueAtIndex(mutable_array_ref, 0, str5); // replacing value at 0!! 568 CFArraySetValueAtIndex(mutable_array_ref, 4, str6); 569 CFArraySetValueAtIndex(mutable_array_ref, 5, str7); 570 CFArraySetValueAtIndex(mutable_array_ref, 6, str8); 571 CFArraySetValueAtIndex(mutable_array_ref, 7, str9); 572 CFArraySetValueAtIndex(mutable_array_ref, 8, str10); 573 CFArraySetValueAtIndex(mutable_array_ref, 9, str11); 574 CFArraySetValueAtIndex(mutable_array_ref, 10, str12); 575 576 CFBinaryHeapRef binheap_ref = 577 CFBinaryHeapCreate(NULL, 15, &kCFStringBinaryHeapCallBacks, NULL); 578 CFBinaryHeapAddValue(binheap_ref, str1); 579 CFBinaryHeapAddValue(binheap_ref, str2); 580 CFBinaryHeapAddValue(binheap_ref, str3); 581 CFBinaryHeapAddValue(binheap_ref, str4); 582 CFBinaryHeapAddValue(binheap_ref, str5); 583 CFBinaryHeapAddValue(binheap_ref, str6); 584 CFBinaryHeapAddValue(binheap_ref, str7); 585 CFBinaryHeapAddValue(binheap_ref, str8); 586 CFBinaryHeapAddValue(binheap_ref, str9); 587 CFBinaryHeapAddValue(binheap_ref, str10); 588 CFBinaryHeapAddValue(binheap_ref, str11); 589 CFBinaryHeapAddValue(binheap_ref, str12); 590 CFBinaryHeapAddValue(binheap_ref, strA1); 591 CFBinaryHeapAddValue(binheap_ref, strB1); 592 CFBinaryHeapAddValue(binheap_ref, strC1); 593 CFBinaryHeapAddValue(binheap_ref, strA11); 594 CFBinaryHeapAddValue(binheap_ref, strB11); 595 CFBinaryHeapAddValue(binheap_ref, strC11); 596 CFBinaryHeapAddValue(binheap_ref, strB12); 597 CFBinaryHeapAddValue(binheap_ref, strC12); 598 CFBinaryHeapAddValue(binheap_ref, strA12); 599 600 CFURLRef cfurl_ref = 601 CFURLCreateWithString(NULL, CFSTR("http://www.foo.bar/"), NULL); 602 CFURLRef cfchildurl_ref = 603 CFURLCreateWithString(NULL, CFSTR("page.html"), cfurl_ref); 604 CFURLRef cfgchildurl_ref = 605 CFURLCreateWithString(NULL, CFSTR("?whatever"), cfchildurl_ref); 606 607 NSDictionary *error_userInfo = @{@"a" : @1, @"b" : @2}; 608 NSError *nserror = [[NSError alloc] initWithDomain:@"Foobar" 609 code:12 610 userInfo:error_userInfo]; 611 NSError **nserrorptr = &nserror; 612 613 NSBundle *bundle_string = [[NSBundle alloc] 614 initWithPath:@"/System/Library/Frameworks/Accelerate.framework"]; 615 NSBundle *bundle_url = [[NSBundle alloc] 616 initWithURL:[[NSURL alloc] 617 initWithString:@"file://localhost/System/Library/" 618 @"Frameworks/Foundation.framework"]]; 619 620 NSBundle *main_bundle = [NSBundle mainBundle]; 621 622 NSArray *bundles = [NSBundle allBundles]; 623 624 NSURL *nsurl0; 625 626 for (NSBundle *bundle in bundles) { 627 nsurl0 = [bundle bundleURL]; 628 } 629 630 NSException *except0 = [[NSException alloc] initWithName:@"TheGuyWhoHasNoName" 631 reason:@"First" 632 userInfo:nil]; 633 NSException *except1 = 634 [[NSException alloc] initWithName:@"TheGuyWhoHasNoName~1" 635 reason:@"Second" 636 userInfo:nil]; 637 NSException *except2 = 638 [[NSException alloc] initWithName:@"TheGuyWhoHasNoName`2" 639 reason:@"Third" 640 userInfo:nil]; 641 NSException *except3 = 642 [[NSException alloc] initWithName:@"TheGuyWhoHasNoName/3" 643 reason:@"Fourth" 644 userInfo:nil]; 645 646 NSURL *nsurl = [[NSURL alloc] initWithString:@"http://www.foo.bar"]; 647 NSURL *nsurl2 = [NSURL URLWithString:@"page.html" relativeToURL:nsurl]; 648 NSURL *nsurl3 = [NSURL URLWithString:@"?whatever" relativeToURL:nsurl2]; 649 650 NSDate *date1 = [NSDate 651 dateWithTimeIntervalSince1970:133890 * 60 * 60]; // 6pm April 10, 1985 GMT 652 NSDate *date2 = 653 [NSDate dateWithNaturalLanguageString:@"12am January 1, 2011"]; 654 NSDate *date3 = [NSDate date]; 655 NSDate *date4 = [NSDate dateWithTimeIntervalSince1970:24 * 60 * 60]; 656 NSDate *date5 = 657 [NSDate dateWithTimeIntervalSinceReferenceDate: 658 floor([[NSDate date] timeIntervalSinceReferenceDate])]; 659 660 NSDate *date_1970_minus_06 = [NSDate dateWithTimeIntervalSince1970:-0.6]; 661 NSDate *date_1970_minus_05 = [NSDate dateWithTimeIntervalSince1970:-0.5]; 662 NSDate *date_1970_minus_04 = [NSDate dateWithTimeIntervalSince1970:-0.4]; 663 664 NSDate *date_1970_plus_06 = [NSDate dateWithTimeIntervalSince1970:0.6]; 665 NSDate *date_1970_plus_05 = [NSDate dateWithTimeIntervalSince1970:0.5]; 666 NSDate *date_1970_plus_04 = [NSDate dateWithTimeIntervalSince1970:0.4]; 667 668 NSDate *distant_past = [NSDate distantPast]; 669 NSDate *distant_future = [NSDate distantFuture]; 670 671 CFAbsoluteTime date1_abs = CFDateGetAbsoluteTime(date1); 672 CFAbsoluteTime date2_abs = CFDateGetAbsoluteTime(date2); 673 CFAbsoluteTime date3_abs = CFDateGetAbsoluteTime(date3); 674 CFAbsoluteTime date4_abs = CFDateGetAbsoluteTime(date4); 675 CFAbsoluteTime date5_abs = CFDateGetAbsoluteTime(date5); 676 677 NSIndexSet *iset1 = 678 [[NSIndexSet alloc] initWithIndexesInRange:NSMakeRange(1, 4)]; 679 NSIndexSet *iset2 = 680 [[NSIndexSet alloc] initWithIndexesInRange:NSMakeRange(1, 512)]; 681 682 NSMutableIndexSet *imset = [[NSMutableIndexSet alloc] init]; 683 [imset addIndex:1936]; 684 [imset addIndex:7]; 685 [imset addIndex:9]; 686 [imset addIndex:11]; 687 [imset addIndex:24]; 688 [imset addIndex:41]; 689 [imset addIndex:58]; 690 [imset addIndex:61]; 691 [imset addIndex:62]; 692 [imset addIndex:63]; 693 694 CFTimeZoneRef cupertino = CFTimeZoneCreateWithName(NULL, CFSTR("PST"), YES); 695 CFTimeZoneRef home = 696 CFTimeZoneCreateWithName(NULL, CFSTR("Europe/Rome"), YES); 697 CFTimeZoneRef europe = CFTimeZoneCreateWithName(NULL, CFSTR("CET"), YES); 698 699 NSTimeZone *cupertino_ns = [NSTimeZone timeZoneWithAbbreviation:@"PST"]; 700 NSTimeZone *home_ns = [NSTimeZone timeZoneWithName:@"Europe/Rome"]; 701 NSTimeZone *europe_ns = [NSTimeZone timeZoneWithAbbreviation:@"CET"]; 702 703 CFGregorianUnits cf_greg_units = {1, 3, 5, 12, 5, 7}; 704 CFGregorianDate cf_greg_date = 705 CFAbsoluteTimeGetGregorianDate(CFDateGetAbsoluteTime(date1), NULL); 706 CFRange cf_range = {4, 4}; 707 NSPoint ns_point = {4, 4}; 708 NSRange ns_range = {4, 4}; 709 710 NSRect ns_rect = {{1, 1}, {5, 5}}; 711 NSRect *ns_rect_ptr = &ns_rect; 712 NSRectArray ns_rect_arr = &ns_rect; 713 NSSize ns_size = {5, 7}; 714 NSSize *ns_size_ptr = &ns_size; 715 716 CGSize cg_size = {1, 6}; 717 CGPoint cg_point = {2, 7}; 718 CGRect cg_rect = {{1, 2}, {7, 7}}; 719 720#ifndef IOS 721 RGBColor rgb_color = {3, 56, 35}; 722 RGBColor *rgb_color_ptr = &rgb_color; 723#endif 724 725 Rect rect = {4, 8, 4, 7}; 726 Rect *rect_ptr = ▭ 727 728 Point point = {7, 12}; 729 Point *point_ptr = &point; 730 731#ifndef IOS 732 HIPoint hi_point = {7, 12}; 733 HIRect hi_rect = {{3, 5}, {4, 6}}; 734#endif 735 736 SEL foo_selector = @selector(foo_selector_impl); 737 738 CFMutableBitVectorRef mut_bv = CFBitVectorCreateMutable(NULL, 64); 739 CFBitVectorSetCount(mut_bv, 50); 740 CFBitVectorSetBitAtIndex(mut_bv, 0, 1); 741 CFBitVectorSetBitAtIndex(mut_bv, 1, 1); 742 CFBitVectorSetBitAtIndex(mut_bv, 2, 1); 743 CFBitVectorSetBitAtIndex(mut_bv, 5, 1); 744 CFBitVectorSetBitAtIndex(mut_bv, 6, 1); 745 CFBitVectorSetBitAtIndex(mut_bv, 8, 1); 746 CFBitVectorSetBitAtIndex(mut_bv, 10, 1); 747 CFBitVectorSetBitAtIndex(mut_bv, 11, 1); 748 CFBitVectorSetBitAtIndex(mut_bv, 16, 1); 749 CFBitVectorSetBitAtIndex(mut_bv, 17, 1); 750 CFBitVectorSetBitAtIndex(mut_bv, 19, 1); 751 CFBitVectorSetBitAtIndex(mut_bv, 20, 1); 752 CFBitVectorSetBitAtIndex(mut_bv, 22, 1); 753 CFBitVectorSetBitAtIndex(mut_bv, 24, 1); 754 CFBitVectorSetBitAtIndex(mut_bv, 28, 1); 755 CFBitVectorSetBitAtIndex(mut_bv, 29, 1); 756 CFBitVectorSetBitAtIndex(mut_bv, 30, 1); 757 CFBitVectorSetBitAtIndex(mut_bv, 30, 1); 758 CFBitVectorSetBitAtIndex(mut_bv, 31, 1); 759 CFBitVectorSetBitAtIndex(mut_bv, 34, 1); 760 CFBitVectorSetBitAtIndex(mut_bv, 35, 1); 761 CFBitVectorSetBitAtIndex(mut_bv, 37, 1); 762 CFBitVectorSetBitAtIndex(mut_bv, 39, 1); 763 CFBitVectorSetBitAtIndex(mut_bv, 40, 1); 764 CFBitVectorSetBitAtIndex(mut_bv, 41, 1); 765 CFBitVectorSetBitAtIndex(mut_bv, 43, 1); 766 CFBitVectorSetBitAtIndex(mut_bv, 47, 1); 767 768 Molecule *molecule = [Molecule new]; 769 770 Class myclass = NSClassFromString(@"NSValue"); 771 Class myclass2 = [str0 class]; 772 Class myclass3 = [molecule class]; 773 Class myclass4 = NSClassFromString(@"NSMutableArray"); 774 Class myclass5 = [nil class]; 775 776 NSArray *components = @[ @"usr", @"blah", @"stuff" ]; 777 NSString *path = [NSString pathWithComponents:components]; 778 779 [molecule addObserver:[My_KVO_Observer new] 780 forKeyPath:@"atoms" 781 options:0 782 context:NULL]; // Set break point at this line. 783 [newMutableDictionary addObserver:[My_KVO_Observer new] 784 forKeyPath:@"weirdKeyToKVO" 785 options:NSKeyValueObservingOptionNew 786 context:NULL]; 787 788 [molecule setAtoms:nil]; 789 [molecule setAtoms:[NSMutableArray new]]; 790 791 [pool drain]; 792 return 0; 793} 794