1. Objective C / Говнокод #17101

    −382

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    if (present) {
            // only if not pull down
            _isLoading = !self.refreshControl.isRefreshing;
            
            self.tableView.userInteractionEnabled = NO;
        }
        if (!present) {
            _isLoading = NO;
            
            self.tableView.userInteractionEnabled = YES;
        }

    stanislaw, 12 Ноября 2014

    Комментарии (2)
  2. Objective C / Говнокод #17094

    −396

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    @implementation SlideMenuNavigationBar
    
    - (void)layoutSubviews
    {
        [super layoutSubviews];
    
        for (UIView *aView in self.subviews) {
            
            // Correcting menu toggle button position
            if ([[aView.class description] isEqualToString:@"UIButton"] && aView.frame.origin.x < self.frame.size.width/2) {
                CGRect frame = aView.frame;
                frame.origin.x = 12; // 8 for correlation
                frame.origin.y = -1; // 1 for correlation
                aView.frame = frame;
            }
            
            if (aView.frame.origin.x > self.frame.size.width/2 && !isIPad && ![[aView.class description] isEqualToString:@"ColoredView"]) {
                CGRect frame = aView.frame;
                frame.origin.x = 260; // 8 for correlation
                frame.origin.y = -1;  // 1 for correlation
                aView.frame = frame;
            }
            
            // Correcting back button and right button positions
            if ([[aView.class description] isEqualToString:@"_UINavigationBarBackIndicatorView"]) {
                CGRect frame = aView.frame;
                frame.origin.y = [self.class navigationBarHeight] - kDefaultNavigationBarHeight + 5; // 5 for correlation
                aView.frame = frame;
            }
            if ([[aView.class description] isEqualToString:@"UINavigationButton"]) {
                CGRect frame = aView.frame;
                frame.origin.y = [self.class navigationBarHeight] - kDefaultNavigationBarHeight + 2; // 2 for correlation
                aView.frame = frame;
            }
            
            if ([aView isKindOfClass:[NavigationBarButton class]]) {
                CGRect frame = aView.frame;
                frame.origin.x = 278; // 8 for correlation
                frame.origin.y = 6;   // 1 for correlation
                aView.frame = frame;
            }
        }
    }
    
    @end

    фиг знает что думали :D

    l0gg3r, 11 Ноября 2014

    Комментарии (6)
  3. Objective C / Говнокод #16907

    −399

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    id  obj =  [[FHSTwitterEngine sharedEngine] getHomeTimelineSinceID:nil count:100];
    
          if ( ![[[obj class] description] isEqualToString:@"NSError"] &&
              ![[[obj class] description] isEqualToString:@"NSURLError"])
     {
         if ([_categoriesDelegate respondsToSelector:@selector(didGetPostFromMyTW: forFeed:)])
             [_categoriesDelegate didGetPostFromMyTW:obj forFeed:@{@"id":feedId}];
     }
          else
              [SVProgressHUD dismiss];

    оригинальное форматирование сохранено

    heyyou, 22 Октября 2014

    Комментарии (2)
  4. Objective C / Говнокод #16823

    −405

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    float scaleFactor = param1/172;
            if (scaleFactor < -1)
            {
                scaleFactor = -1;
            }
            _releaseTheKraken.transform = CGAffineTransformMakeScale(-scaleFactor,-scaleFactor);
            float krakenPosition = param1/2.4571;
            
            if (param1<-172)
            {
                krakenPosition = -70 + 172 + param1;
                _activityIndicator.center = CGPointMake(25, param1+15);
            }
            _releaseTheKraken.center = CGPointMake(147.5, krakenPosition);
            if (param1<-100)
            {
                float param2 = (-param1 - 100)/7.5;
                int param3 = floor(param2);
                if (param3<10)
                {...

    soprof, 08 Октября 2014

    Комментарии (11)
  5. Objective C / Говнокод #16789

    −398

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        
        UIBarButtonItem *saveButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Save", nil) style:UIBarButtonItemStylePlain target:self action:@selector(save:)];
        
        // ...
    
        self.navigationItem.rightBarButtonItems = @[saveButton, someOtherButton];
    
        self.saveBarButtonItem = saveButton;
    }
    
    - (void)someMethod
    {
        [self.navigationItem.rightBarButtonItems enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop){
            UIBarButtonItem *barItem = (UIBarButtonItem *)obj;
            if ([barItem.title isEqualToString:NSLocalizedString(@"Save", nil)]) {
                barItem.enabled = NO;
            }
        }];
    }

    Задача: включать/выключать кнопку по определенному событию.

    gumbert, 02 Октября 2014

    Комментарии (1)
  6. Objective C / Говнокод #16788

    −413

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    - (void)webViewDidFinishLoad:(UIWebView *)webView {
        [TMSpinner hide];
        if (self.registrationModel && !self.loggedIn && [[self.webView.request.URL absoluteString] length]) {
            [self autologinTheWebView];
        }
    }
    
    #pragma mark - Black magic
    
    - (void)autologinTheWebView {
        [self.webView stringByEvaluatingJavaScriptFromString:[self javascriptToInject]];
        [self.webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"autologin('%@', '%@');", self.registrationModel.email, self.registrationModel.password]];
        self.loggedIn = YES;
    }
    
    - (NSString *)javascriptToInject {
        return @"autologin = function(email, password) {"
               @"  var emailField = document.getElementById('user_email');"
               @"  var passwordField = document.getElementById('user_password');"
               @"  var submitButton = document.querySelector('input.btn.btn-default.btn-success');"
               @"  emailField.value = email;"
               @"  passwordField.value = password;"
               @"  submitButton.click();"
               @"};";
    }

    js в obj-c. кому то после меня это поддерживать :)

    Drenwtc, 02 Октября 2014

    Комментарии (5)
  7. Objective C / Говнокод #16751

    −393

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    - (void)config
    {
        self.contentView.backgroundColor = [UIColor NaviCellBgColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        UIImageView *theDisclosureView = _disclosureView;
        UILabel *theLabel = _titleLabel;
        if (self.isHighlighted)
        {
            theLabel.shadowColor = [UIColor TextShadowColor];
            theLabel.shadowOffset = CGSizeMake(0.0f, -0.5f);
            self.contentView.backgroundColor = [UIColor NaviCellBgHighlightColor];
            theLabel.textColor = [UIColor GreenTextColor];
            self.contentView.backgroundColor = [UIColor NaviCellBgHighlightColor];
            theDisclosureView.image = [UIImage imageNamed:@"Button_Disclosure_touch"];
        }
        else
        {
            theLabel.shadowColor = [UIColor TextShadowColor];
            theLabel.shadowOffset = CGSizeMake(0.0f, -0.5f);
            self.contentView.backgroundColor = [UIColor NaviCellBgHighlightColor];
            theLabel.textColor = [UIColor GreenTextColor];
            self.contentView.backgroundColor = [UIColor NaviCellBgColor];
            theDisclosureView.image = [UIImage imageNamed:@"Button_Disclosure"];
        }
    
        UIActivityIndicatorView *theIndicator = _loadingIndicator;
        if (_loading)
            [theIndicator startAnimating];
        else
            [theIndicator stopAnimating];
        
        UILabel *theTitleLabel = _titleLabel;
        theTitleLabel.textColor = [UIColor GreenTextColor];
    }

    Код вид культурного европэйця. Справжний европейский кодстайл.

    Psionic, 23 Сентября 2014

    Комментарии (0)
  8. Objective C / Говнокод #16680

    −405

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    -(BOOL)isForEvenNumberPage
    {
        return self.pageNumber % 2 == 0;
    }
    
    -(BOOL)isForOddNumberPage
    {
        return [self isForEvenNumberPage] == NO;
    }

    Один очень крупный проект от заокеанского заказчика

    stonerhawk, 11 Сентября 2014

    Комментарии (88)
  9. Objective C / Говнокод #16673

    −402

    1. 1
    2. 2
    3. 3
    4. 4
    UIDevice* thisDevice = [UIDevice currentDevice];
        char cfunktion[] = {'u', 'n', 'i', 'q', 'u', 'e', 'I', 'd', 'e', 'n', 't', 'i', 'f', 'i', 'e', 'r',0};
        SEL udid = NSSelectorFromString([NSString stringWithUTF8String:cfunktion]);
        id identifier =[thisDevice performSelector:udid];

    Безпалевно вызываем скрытые апи.

    Psionic, 09 Сентября 2014

    Комментарии (3)
  10. Objective C / Говнокод #16494

    −396

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    - (void)isCharityPost: (BOOL)charityPost{
        self.charityButton.hidden = charityPost ? NO : YES;
        self.cashBadgeButton.hidden = charityPost ? NO : YES;
        
        [self updateCharityButtonWithText:self.charityButton.titleLabel.text];
    }

    Production-код.
    Пунктуация сохранена.

    nshipster, 06 Августа 2014

    Комментарии (2)