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

    −411

    1. 1
    2. 2
    NSDate *dateFromString = [[NSDate alloc] init];
    dateFromString = [dateFormatter dateFromString:cell.textFieldCell.text];

    Когда человек не знает, что делает

    ep_fl, 17 Апреля 2015

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

    −425

    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
    [self.userView sd_setImageWithURL:[comment.sender avatarThumbnailURL] placeholderImage:[UIImage coloredAvatarWithId:[NSString stringWithFormat:@"%lld", comment.sender.idValue]
    																									 andName:comment.sender.firstName
    																									  ofSize:CGSizeMake (57, 57)]];
    
    	self.dateLabel.text = [self tsFromDate:comment.createdAt];
    
    	[self.dateLabel sizeToFit];
    
    	if (comment.sender == [SWCore account])
    	{
    		self.balloonImage.image = [[UIImage imageNamed:@"in_baloon"] resizableStretchedImageWithCapInsets:UIEdgeInsetsMake (20, 50, 20, 50)];
    
    		self.messageLabel.textColor = [UIColor colorWithWhite:.4f alpha:1.0f];
    
    		self.userView.left = 20;
    		self.balloonImage.right = 300;
    		self.dateLabel.right = self.balloonImage.right;
    		self.dateIcon.right = self.dateLabel.left - 3;
    	}
    	else
    	{
    		self.balloonImage.image = [[UIImage imageNamed:@"out_baloon"] resizableStretchedImageWithCapInsets:UIEdgeInsetsMake (20, 50, 20, 50)];
    
    		self.messageLabel.textColor = [UIColor whiteColor];
    
    		self.userView.right = 300;
    		self.balloonImage.left = 20;
    		self.dateIcon.left = self.balloonImage.left;
    		self.dateLabel.left = self.dateIcon.right + 3;
    	}

    Мастерское владение размерами

    shadeapps, 06 Апреля 2015

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

    −352

    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
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    98. 98
    99. 99
    - (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
    	UITableViewCell *cell = nil;
    
    	if (indexPath.row == self.titles.count - 1)
    	{
    		cell = [tableView dequeueReusableCellWithIdentifier:@"settingButtonCell" forIndexPath:indexPath];
    
    		SWSettingButtonCell *scell = (SWSettingButtonCell *) cell;
    
    		[scell.settingButton setTitleForAllStates:self.titles[indexPath.row]];
    
    		[scell.settingButton bk_removeEventHandlersForControlEvents:UIControlEventTouchUpInside];
    
    		scell.settingIcon.visible = YES;
    
    		@weakify(self);
    		[scell.settingButton bk_addEventHandler:^(id sender) {
    			[UIAlertView bk_showAlertViewWithTitle:@"Logout"
    										   message:@"Do you want to logout?"
    								 cancelButtonTitle:@"NO"
    								 otherButtonTitles:@[@"YES"]
    										   handler:^(UIAlertView *alertView, NSInteger buttonIndex) {
    											   @strongify(self);
    
    											   if (buttonIndex != 0)
    											   {
    												   [[SWCore instance] logout];
                                                       // fix
                                                       [SVProgressHUD show];
                                                       // end fix
    											   }
    										   }];
    		}                      forControlEvents:UIControlEventTouchUpInside];
    	}
    	else if (indexPath.row == self.titles.count - 2)
    	{
    		cell = [tableView dequeueReusableCellWithIdentifier:@"settingButtonCell" forIndexPath:indexPath];
    
    		SWSettingButtonCell *scell = (SWSettingButtonCell *) cell;
    
    		[scell.settingButton setTitleForAllStates:self.titles[indexPath.row]];
    
    		[scell.settingButton bk_removeEventHandlersForControlEvents:UIControlEventTouchUpInside];
    
    		scell.settingIcon.visible = NO;
    
    		@weakify(self);
    		[scell.settingButton bk_addEventHandler:^(id sender) {
    
    			@strongify(self);
    			[self performSegueWithIdentifier:@"pushSettingsSegue" sender:nil];
    		}                      forControlEvents:UIControlEventTouchUpInside];
    	}
    	else
    	{
    		cell = [tableView dequeueReusableCellWithIdentifier:@"settingCell" forIndexPath:indexPath];
    
    		SWSettingCell *scell = (SWSettingCell *) cell;
    
    		scell.settingLabel.text = self.titles[indexPath.row];
    		[scell.settingIcon setImage:self.icons[indexPath.row]];
    
    		switch (indexPath.row)
    		{
    			case 0:
    			{
    				scell.settingSwitch.on  = [[SWCore account].settings[[NSString stringWithFormat:SETTINGS_PROFILE_VISIBILITY]] isEqualToString:SETTING_PUBLIC];
    				scell.settingIcon.image = scell.settingSwitch.isOn ? [UIImage imageNamed:@"settings_profile_icon_on"] : [UIImage imageNamed:@"settings_profile_icon_off"];
    			}
    				break;
    
    			case 1:
    			{
    				scell.settingSwitch.on  = [[SWCore account].settings[[NSString stringWithFormat:SETTINGS_EVENTS_VISIBILITY]] isEqualToString:SETTING_PUBLIC];
    				scell.settingIcon.image = scell.settingSwitch.isOn ? [UIImage imageNamed:@"settings_events_button_on"] : [UIImage imageNamed:@"settings_events_button_off"];
    			}
    				break;
    
    			case 2:
    			{
    				scell.settingSwitch.on  = [[SWCore account].settings[[NSString stringWithFormat:SETTINGS_PHONE_VISIBILITY]] isEqualToString:SETTING_PUBLIC];
    				scell.settingIcon.image = scell.settingSwitch.isOn ? [UIImage imageNamed:@"settings_phone_button_on"] : [UIImage imageNamed:@"settings_phone_button_off"];
    			}
    				break;
    
    			case 3:
    			{
    				scell.settingSwitch.on  = [[SWCore account].settings[[NSString stringWithFormat:SETTINGS_PHOTOS_VISIBILITY]] isEqualToString:SETTING_PUBLIC];
    				scell.settingIcon.image = scell.settingSwitch.isOn ? [UIImage imageNamed:@"settings_photos_button_on"] : [UIImage imageNamed:@"settings_photos_button_off"];
    			}
    				break;
    
    			default:
    				break;
    		}
    
    		scell.settingSwitch.tag = indexPath.row;
    		[scell.settingSwitch bk_removeEventHandlersForControlEvents:UIControlEventValueChanged];

    Один из самых классных методов cellForRowAtIndexPath что я когда-либо видел

    shadeapps, 06 Апреля 2015

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

    −403

    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
    if (indexPath.row == 0) {
            if (![centerViewController isKindOfClass:[T7DUserInfoViewController class]]) {
                T7DUserInfoViewController *userViewController = [[T7DUserInfoViewController alloc] init];
                [navigationController popViewControllerAnimated:NO];
                [navigationController pushViewController:userViewController animated:NO];
            }
        }
        if (indexPath.row == 1) {
            if (![centerViewController isKindOfClass:[T7DMapViewController class]]) {
                T7DMapViewController *mapViewController = [[T7DMapViewController alloc] init];
                [navigationController popViewControllerAnimated:NO];
                [navigationController pushViewController:mapViewController animated:NO];
            }
        }
        if (indexPath.row == 2) {
            if (![centerViewController isKindOfClass:[T7DOrderListViewController class]]) {
                T7DOrderListViewController *orderListViewController = [[T7DOrderListViewController alloc] init];
                [navigationController popViewControllerAnimated:NO];
                [navigationController pushViewController:orderListViewController animated:NO];
            }
        }
        if (indexPath.row == 3) {
            if (![centerViewController isKindOfClass:[T7DCurrentOrderViewController class]]) {
                T7DCurrentOrderViewController *orderViewController = [[T7DCurrentOrderViewController alloc] init];
                [orderViewController setOrderType:T7DOrderTypeCurrent];
                [orderViewController setOrder:[T7DOrder currentOrder]];
                [navigationController popViewControllerAnimated:NO];
                [navigationController pushViewController:orderViewController animated:NO];
            }
        }
        if (indexPath.row == 4) {
            if (![centerViewController isKindOfClass:[T7DMessagesViewController class]]) {
                T7DMessagesViewController *messagesViewConroller = [[T7DMessagesViewController alloc] init];
                [navigationController popViewControllerAnimated:NO];
                [navigationController pushViewController:messagesViewConroller animated:NO];
            }
        }
        if (indexPath.row == 5) {
            [self logout];
            return;
        }

    Мудаки.

    pr0gl, 31 Марта 2015

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

    −407

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    Код конца 2014 года
    
        CGSize iOSDeviceScreenSize = [[UIScreen mainScreen] bounds].size;
        if (iOSDeviceScreenSize.height == 480)
            isRetina = true;
        else
            isRetina = false;5

    Headless, 23 Марта 2015

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

    −407

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    #define RETURN_CREATED_SGINGLETON_MUTABLE_ARRAY \
      static NSMutableArray* _singletonArray = nil; \
      static dispatch_once_t onceToken; \
      dispatch_once(&onceToken, ^{ \
        _singletonArray = [[NSMutableArray alloc] init]; \
      }); \
      return _singletonArray;

    Используется массив для хранения заданий. Эдакий самописный NSOperationQueue.

    ProFFeSSoR, 23 Марта 2015

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

    −397

    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
    [array_static removeAllObjects];
    [array_static addObject:@"Files"];
    [array addObjectsFromArray:[filemanager contentsOfDirectoryAtPath:DOCUMENTS error:nil]];
    
    for (int l=0; l<array.count; l++) {
    	for (int j=0; j<array.count; j++) {
    		for (int i=0; i<array.count; i++) {
    			if ([[array objectAtIndex:i] rangeOfString:@"."].location != NSNotFound) {
    				[array removeObjectAtIndex:i];
    			}
    		}
    	}
    }
    
    for (int i = 0; i<array.count; i++) {
    	if (![array_static containsObject:[array objectAtIndex:i]]) {
    		[array_static addObject:[array objectAtIndex:i]];
    	}
    }

    Дали задание добавить фичу в один старый проект. Открыл проект, сижу и наслаждаюсь видом 8)

    OUrsus, 16 Марта 2015

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

    −387

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    @implementation UINavigationController (LastControllerBar)
    
    - (UIStatusBarStyle)preferredStatusBarStyle {
        if (self.viewControllers.count)
            return [[self.viewControllers lastObject] preferredStatusBarStyle];
        return UIStatusBarStyleDefault;
    }
    @end

    Категория из VKSDK: https://github.com/VKCOM/vk-ios-sdk/blob/master/sdk/Source/Views/VKAuthorizeController.m
    Долго разбирался, почему у меня буквы в статусбаре стали чёрными.

    watupiwa, 27 Февраля 2015

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

    −388

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    - (void) setLevel:(NSInteger)level {
        if (level > (long)[_ranksDictionary count] - 1) level = (long)[_ranksDictionary count] - 1;
        if (level < 0) level = 0;
    
        _level = level;
        
        self.currentRank = [_ranksDictionary objectForKey:[NSNumber numberWithInteger:_level]];
        
        if (rankDataItem.integerValue != -_level)
            rankDataItem.integerValue = _level;
    }

    Я совсем хуевый?

    ExT, 28 Января 2015

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

    −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
    BOOL = omg;
        
        if (omg == YES)
        {
            [self go];
        }
        else
        {
            if (omg == YES)
            {
                omg = YES;
                [self go];
            }
        }

    МОИ ГЛАЗАААА

    ShuZik, 23 Января 2015

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