Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. @implementation Test1 {
  2. NSString *stringProp;
  3. }
  4.  
  5. - (instancetype)init {
  6. self = [super init];
  7. if (self) {
  8. [self test];
  9. }
  10.  
  11. return self;
  12. }
  13.  
  14. - (void)test {
  15. dispatch_async(dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0), ^{
  16. dispatch_apply(10000000, dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0), ^(size_t i) {
  17. stringProp = [[NSString alloc] initWithFormat:@"%lu", i];
  18. });
  19. });
  20.  
  21. dispatch_async(dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0), ^{
  22. dispatch_apply(100000, dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^(size_t i) {
  23. NSString *string = stringProp;
  24. [self print:string];
  25. });
  26. });
  27. }
  28.  
  29.  
  30. - (void)print:(NSString * __unsafe_unretained)string {
  31. NSLog(@"%@", string);
  32. }
  33.  
  34. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement