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 id cfKeys[4] = {@"foo", @"bar", @"baz", @"quux"}; 480 id cfValues[4] = {@"foo", @"bar", @"baz", @"quux"}; 481 NSDictionary *nsDictionary = CFBridgingRelease( 482 CFDictionaryCreate(nil, (void *)cfKeys, (void *)cfValues, 2, nil, nil)); 483 NSDictionary *nscfDictionary = CFBridgingRelease( 484 CFDictionaryCreate(nil, (void *)cfKeys, (void *)cfValues, 4, nil, nil)); 485 CFDictionaryRef cfDictionaryRef = 486 CFDictionaryCreate(nil, (void *)cfKeys, (void *)cfValues, 3, nil, nil); 487 488 NSAttributedString *attrString = 489 [[NSAttributedString alloc] initWithString:@"hello world from foo" 490 attributes:newDictionary]; 491 [attrString isEqual:nil]; 492 NSAttributedString *mutableAttrString = 493 [[NSMutableAttributedString alloc] initWithString:@"hello world from foo" 494 attributes:newDictionary]; 495 [mutableAttrString isEqual:nil]; 496 497 NSString *mutableString = [[NSMutableString alloc] initWithString:@"foo"]; 498 [mutableString 499 insertString: 500 @"foo said this string needs to be very long so much longer than " 501 @"whatever other string has been seen ever before by anyone of the " 502 @"mankind that of course this is still not long enough given what " 503 @"foo our friend foo our lovely dearly friend foo desired of us so i " 504 @"am adding more stuff here for the sake of it and for the joy of " 505 @"our friend who is named guess what just foo. hence, dear friend " 506 @"foo, stay safe, your string is now long enough to accommodate " 507 @"your testing need and I will make sure that if not we extend it " 508 @"with even more fuzzy random meaningless words pasted one after the " 509 @"other from a long tiresome friday evening spent working in my " 510 @"office. my office mate went home but I am still randomly typing " 511 @"just for the fun of seeing what happens of the length of a Mutable " 512 @"String in Cocoa if it goes beyond one byte.. so be it, dear " 513 atIndex:0]; 514 515 NSString *mutableGetConst = 516 [NSString stringWithCString:[mutableString cString]]; 517 518 [mutableGetConst length]; 519 520 NSData *immutableData = [[NSData alloc] initWithBytes:"HELLO" length:5]; 521 NSData *mutableData = [[NSMutableData alloc] initWithBytes:"NODATA" length:6]; 522 523 // No-copy versions of NSData initializers use NSConcreteData if over 2^16 524 // elements are specified. 525 unsigned concreteLength = 100000; 526 void *zeroes1 = calloc(1, concreteLength); 527 // initWithBytesNoCopy takes ownership of the buffer. 528 NSData *concreteData = [[NSData alloc] initWithBytesNoCopy:zeroes1 529 length:concreteLength]; 530 void *zeroes2 = calloc(1, concreteLength); 531 NSMutableData *concreteMutableData = 532 [[NSMutableData alloc] initWithBytesNoCopy:zeroes2 length:concreteLength]; 533 534 [mutableData appendBytes:"MOREDATA" length:8]; 535 536 [immutableData length]; 537 [mutableData length]; 538 539 NSSet *nsset = [[NSSet alloc] initWithObjects:str1, str2, str3, nil]; 540 NSSet *nsmutableset = 541 [[NSMutableSet alloc] initWithObjects:str1, str2, str3, nil]; 542 [nsmutableset addObject:str4]; 543 NSSet *nscfSet = 544 CFBridgingRelease(CFSetCreate(nil, (void *)cfValues, 2, nil)); 545 546 CFDataRef data_ref = 547 CFDataCreate(kCFAllocatorDefault, [immutableData bytes], 5); 548 549 CFMutableDataRef mutable_data_ref = 550 CFDataCreateMutable(kCFAllocatorDefault, 8); 551 CFDataAppendBytes(mutable_data_ref, [mutableData bytes], 5); 552 553 CFMutableStringRef mutable_string_ref = CFStringCreateMutable(NULL, 100); 554 CFStringAppend(mutable_string_ref, CFSTR("Wish ya knew")); 555 556 CFStringRef cfstring_ref = CFSTR("HELLO WORLD"); 557 558 CFArrayRef cfarray_ref = CFArrayCreate(NULL, data_set, 3, NULL); 559 CFMutableArrayRef mutable_array_ref = CFArrayCreateMutable(NULL, 16, NULL); 560 561 CFArraySetValueAtIndex(mutable_array_ref, 0, str1); 562 CFArraySetValueAtIndex(mutable_array_ref, 1, str2); 563 CFArraySetValueAtIndex(mutable_array_ref, 2, str3); 564 CFArraySetValueAtIndex(mutable_array_ref, 3, str4); 565 CFArraySetValueAtIndex(mutable_array_ref, 0, str5); // replacing value at 0!! 566 CFArraySetValueAtIndex(mutable_array_ref, 4, str6); 567 CFArraySetValueAtIndex(mutable_array_ref, 5, str7); 568 CFArraySetValueAtIndex(mutable_array_ref, 6, str8); 569 CFArraySetValueAtIndex(mutable_array_ref, 7, str9); 570 CFArraySetValueAtIndex(mutable_array_ref, 8, str10); 571 CFArraySetValueAtIndex(mutable_array_ref, 9, str11); 572 CFArraySetValueAtIndex(mutable_array_ref, 10, str12); 573 574 CFBinaryHeapRef binheap_ref = 575 CFBinaryHeapCreate(NULL, 15, &kCFStringBinaryHeapCallBacks, NULL); 576 CFBinaryHeapAddValue(binheap_ref, str1); 577 CFBinaryHeapAddValue(binheap_ref, str2); 578 CFBinaryHeapAddValue(binheap_ref, str3); 579 CFBinaryHeapAddValue(binheap_ref, str4); 580 CFBinaryHeapAddValue(binheap_ref, str5); 581 CFBinaryHeapAddValue(binheap_ref, str6); 582 CFBinaryHeapAddValue(binheap_ref, str7); 583 CFBinaryHeapAddValue(binheap_ref, str8); 584 CFBinaryHeapAddValue(binheap_ref, str9); 585 CFBinaryHeapAddValue(binheap_ref, str10); 586 CFBinaryHeapAddValue(binheap_ref, str11); 587 CFBinaryHeapAddValue(binheap_ref, str12); 588 CFBinaryHeapAddValue(binheap_ref, strA1); 589 CFBinaryHeapAddValue(binheap_ref, strB1); 590 CFBinaryHeapAddValue(binheap_ref, strC1); 591 CFBinaryHeapAddValue(binheap_ref, strA11); 592 CFBinaryHeapAddValue(binheap_ref, strB11); 593 CFBinaryHeapAddValue(binheap_ref, strC11); 594 CFBinaryHeapAddValue(binheap_ref, strB12); 595 CFBinaryHeapAddValue(binheap_ref, strC12); 596 CFBinaryHeapAddValue(binheap_ref, strA12); 597 598 CFURLRef cfurl_ref = 599 CFURLCreateWithString(NULL, CFSTR("http://www.foo.bar/"), NULL); 600 CFURLRef cfchildurl_ref = 601 CFURLCreateWithString(NULL, CFSTR("page.html"), cfurl_ref); 602 CFURLRef cfgchildurl_ref = 603 CFURLCreateWithString(NULL, CFSTR("?whatever"), cfchildurl_ref); 604 605 NSDictionary *error_userInfo = @{@"a" : @1, @"b" : @2}; 606 NSError *nserror = [[NSError alloc] initWithDomain:@"Foobar" 607 code:12 608 userInfo:error_userInfo]; 609 NSError **nserrorptr = &nserror; 610 611 NSBundle *bundle_string = [[NSBundle alloc] 612 initWithPath:@"/System/Library/Frameworks/Accelerate.framework"]; 613 NSBundle *bundle_url = [[NSBundle alloc] 614 initWithURL:[[NSURL alloc] 615 initWithString:@"file://localhost/System/Library/" 616 @"Frameworks/Foundation.framework"]]; 617 618 NSBundle *main_bundle = [NSBundle mainBundle]; 619 620 NSArray *bundles = [NSBundle allBundles]; 621 622 NSURL *nsurl0; 623 624 for (NSBundle *bundle in bundles) { 625 nsurl0 = [bundle bundleURL]; 626 } 627 628 NSException *except0 = [[NSException alloc] initWithName:@"TheGuyWhoHasNoName" 629 reason:@"First" 630 userInfo:nil]; 631 NSException *except1 = 632 [[NSException alloc] initWithName:@"TheGuyWhoHasNoName~1" 633 reason:@"Second" 634 userInfo:nil]; 635 NSException *except2 = 636 [[NSException alloc] initWithName:@"TheGuyWhoHasNoName`2" 637 reason:@"Third" 638 userInfo:nil]; 639 NSException *except3 = 640 [[NSException alloc] initWithName:@"TheGuyWhoHasNoName/3" 641 reason:@"Fourth" 642 userInfo:nil]; 643 644 NSURL *nsurl = [[NSURL alloc] initWithString:@"http://www.foo.bar"]; 645 NSURL *nsurl2 = [NSURL URLWithString:@"page.html" relativeToURL:nsurl]; 646 NSURL *nsurl3 = [NSURL URLWithString:@"?whatever" relativeToURL:nsurl2]; 647 648 NSDate *date1 = [NSDate 649 dateWithTimeIntervalSince1970:133890 * 60 * 60]; // 6pm April 10, 1985 GMT 650 NSDate *date2 = 651 [NSDate dateWithNaturalLanguageString:@"12am January 1, 2011"]; 652 NSDate *date3 = [NSDate date]; 653 NSDate *date4 = [NSDate dateWithTimeIntervalSince1970:24 * 60 * 60]; 654 NSDate *date5 = 655 [NSDate dateWithTimeIntervalSinceReferenceDate: 656 floor([[NSDate date] timeIntervalSinceReferenceDate])]; 657 658 CFAbsoluteTime date1_abs = CFDateGetAbsoluteTime(date1); 659 CFAbsoluteTime date2_abs = CFDateGetAbsoluteTime(date2); 660 CFAbsoluteTime date3_abs = CFDateGetAbsoluteTime(date3); 661 CFAbsoluteTime date4_abs = CFDateGetAbsoluteTime(date4); 662 CFAbsoluteTime date5_abs = CFDateGetAbsoluteTime(date5); 663 664 NSIndexSet *iset1 = 665 [[NSIndexSet alloc] initWithIndexesInRange:NSMakeRange(1, 4)]; 666 NSIndexSet *iset2 = 667 [[NSIndexSet alloc] initWithIndexesInRange:NSMakeRange(1, 512)]; 668 669 NSMutableIndexSet *imset = [[NSMutableIndexSet alloc] init]; 670 [imset addIndex:1936]; 671 [imset addIndex:7]; 672 [imset addIndex:9]; 673 [imset addIndex:11]; 674 [imset addIndex:24]; 675 [imset addIndex:41]; 676 [imset addIndex:58]; 677 [imset addIndex:61]; 678 [imset addIndex:62]; 679 [imset addIndex:63]; 680 681 CFTimeZoneRef cupertino = CFTimeZoneCreateWithName(NULL, CFSTR("PST"), YES); 682 CFTimeZoneRef home = 683 CFTimeZoneCreateWithName(NULL, CFSTR("Europe/Rome"), YES); 684 CFTimeZoneRef europe = CFTimeZoneCreateWithName(NULL, CFSTR("CET"), YES); 685 686 NSTimeZone *cupertino_ns = [NSTimeZone timeZoneWithAbbreviation:@"PST"]; 687 NSTimeZone *home_ns = [NSTimeZone timeZoneWithName:@"Europe/Rome"]; 688 NSTimeZone *europe_ns = [NSTimeZone timeZoneWithAbbreviation:@"CET"]; 689 690 CFGregorianUnits cf_greg_units = {1, 3, 5, 12, 5, 7}; 691 CFGregorianDate cf_greg_date = 692 CFAbsoluteTimeGetGregorianDate(CFDateGetAbsoluteTime(date1), NULL); 693 CFRange cf_range = {4, 4}; 694 NSPoint ns_point = {4, 4}; 695 NSRange ns_range = {4, 4}; 696 697 NSRect ns_rect = {{1, 1}, {5, 5}}; 698 NSRect *ns_rect_ptr = &ns_rect; 699 NSRectArray ns_rect_arr = &ns_rect; 700 NSSize ns_size = {5, 7}; 701 NSSize *ns_size_ptr = &ns_size; 702 703 CGSize cg_size = {1, 6}; 704 CGPoint cg_point = {2, 7}; 705 CGRect cg_rect = {{1, 2}, {7, 7}}; 706 707#ifndef IOS 708 RGBColor rgb_color = {3, 56, 35}; 709 RGBColor *rgb_color_ptr = &rgb_color; 710#endif 711 712 Rect rect = {4, 8, 4, 7}; 713 Rect *rect_ptr = ▭ 714 715 Point point = {7, 12}; 716 Point *point_ptr = &point; 717 718#ifndef IOS 719 HIPoint hi_point = {7, 12}; 720 HIRect hi_rect = {{3, 5}, {4, 6}}; 721#endif 722 723 SEL foo_selector = @selector(foo_selector_impl); 724 725 CFMutableBitVectorRef mut_bv = CFBitVectorCreateMutable(NULL, 64); 726 CFBitVectorSetCount(mut_bv, 50); 727 CFBitVectorSetBitAtIndex(mut_bv, 0, 1); 728 CFBitVectorSetBitAtIndex(mut_bv, 1, 1); 729 CFBitVectorSetBitAtIndex(mut_bv, 2, 1); 730 CFBitVectorSetBitAtIndex(mut_bv, 5, 1); 731 CFBitVectorSetBitAtIndex(mut_bv, 6, 1); 732 CFBitVectorSetBitAtIndex(mut_bv, 8, 1); 733 CFBitVectorSetBitAtIndex(mut_bv, 10, 1); 734 CFBitVectorSetBitAtIndex(mut_bv, 11, 1); 735 CFBitVectorSetBitAtIndex(mut_bv, 16, 1); 736 CFBitVectorSetBitAtIndex(mut_bv, 17, 1); 737 CFBitVectorSetBitAtIndex(mut_bv, 19, 1); 738 CFBitVectorSetBitAtIndex(mut_bv, 20, 1); 739 CFBitVectorSetBitAtIndex(mut_bv, 22, 1); 740 CFBitVectorSetBitAtIndex(mut_bv, 24, 1); 741 CFBitVectorSetBitAtIndex(mut_bv, 28, 1); 742 CFBitVectorSetBitAtIndex(mut_bv, 29, 1); 743 CFBitVectorSetBitAtIndex(mut_bv, 30, 1); 744 CFBitVectorSetBitAtIndex(mut_bv, 30, 1); 745 CFBitVectorSetBitAtIndex(mut_bv, 31, 1); 746 CFBitVectorSetBitAtIndex(mut_bv, 34, 1); 747 CFBitVectorSetBitAtIndex(mut_bv, 35, 1); 748 CFBitVectorSetBitAtIndex(mut_bv, 37, 1); 749 CFBitVectorSetBitAtIndex(mut_bv, 39, 1); 750 CFBitVectorSetBitAtIndex(mut_bv, 40, 1); 751 CFBitVectorSetBitAtIndex(mut_bv, 41, 1); 752 CFBitVectorSetBitAtIndex(mut_bv, 43, 1); 753 CFBitVectorSetBitAtIndex(mut_bv, 47, 1); 754 755 Molecule *molecule = [Molecule new]; 756 757 Class myclass = NSClassFromString(@"NSValue"); 758 Class myclass2 = [str0 class]; 759 Class myclass3 = [molecule class]; 760 Class myclass4 = NSClassFromString(@"NSMutableArray"); 761 Class myclass5 = [nil class]; 762 763 NSArray *components = @[ @"usr", @"blah", @"stuff" ]; 764 NSString *path = [NSString pathWithComponents:components]; 765 766 [molecule addObserver:[My_KVO_Observer new] 767 forKeyPath:@"atoms" 768 options:0 769 context:NULL]; // Set break point at this line. 770 [newMutableDictionary addObserver:[My_KVO_Observer new] 771 forKeyPath:@"weirdKeyToKVO" 772 options:NSKeyValueObservingOptionNew 773 context:NULL]; 774 775 [molecule setAtoms:nil]; 776 [molecule setAtoms:[NSMutableArray new]]; 777 778 [pool drain]; 779 return 0; 780} 781