main.m 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. //
  2. // main.m
  3. // Demo-OSX
  4. //
  5. // Created by C.W. Betts on 6/7/13.
  6. // Copyright (c) 2013 C.W. Betts. All rights reserved.
  7. //
  8. #import <Cocoa/Cocoa.h>
  9. #import <SVGKit/SVGKit.h>
  10. #ifndef TESTSVGKPARSERASYNCHRONOUS
  11. #define TESTSVGKPARSERASYNCHRONOUS 0
  12. #endif
  13. #if TESTSVGKPARSERASYNCHRONOUS
  14. @interface TestDelegate : NSObject <SVGKParserDelegate>
  15. @end
  16. @implementation TestDelegate
  17. - (void)parser:(SVGKParser *)parserPassed DidFinishParsingWithResult:(SVGKParseResult *)result
  18. {
  19. NSLog(@"Parse Complete");
  20. }
  21. @end
  22. #endif
  23. int main(int argc, char *argv[])
  24. {
  25. @autoreleasepool {
  26. [SVGKit enableLogging];
  27. }
  28. #if TESTSVGKPARSERASYNCHRONOUS
  29. //SVGKParser parseAsynchronously tester
  30. @autoreleasepool {
  31. NSString *path = [[NSBundle mainBundle] pathForResource:@"CurvedDiamond" ofType:@"svg"];
  32. SVGKSource *theSource = [SVGKSource sourceFromFilename:path];
  33. SVGKParser *theParser = [[SVGKParser alloc] initWithSource:theSource];
  34. [theParser addDefaultSVGParserExtensions];
  35. [theParser parseAsynchronously];
  36. TestDelegate *theTest = [TestDelegate new];
  37. [theParser parseAsynchronouslyWithDelegate:theTest];
  38. dispatch_async(dispatch_get_global_queue(0, 0), ^{
  39. sleep(20);
  40. dispatch_sync(dispatch_get_main_queue(), ^{
  41. [theParser parseAsynchronouslyWithDelegate:theTest];
  42. });
  43. });
  44. }
  45. #endif
  46. return NSApplicationMain(argc, (const char **)argv);
  47. }