1. Список говнокодов пользователя shadeapps

    Всего: 3

  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

    Комментарии (156)
  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

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

    −416

    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
    - (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
    	if (self.mode == EventsMode)
    	{
    		SWEvent *event = [self.eventsController.dataModel itemAtIndexPath:indexPath];
    
    		static NSString *CellIdentifier = @"actionCell";
    		SWActionCell    *cell           = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
    
    		[cell formatForEvent:event];
    
    		@weakify(self);
    		@weakify(cell);
    
    		if (![cell.actionButton_1 bk_hasEventHandlersForControlEvents:UIControlEventTouchUpInside])
    		{
    			[cell.actionButton_1 bk_addEventHandler:^(id sender) {
    				@strongify(cell);
    
    				SWEvent *cellEvent = cell.event;
    
    				if (cellEvent.isLikedValue)
    				{
    					[[SWCore instance] unlikeEvent:cellEvent];
    				}
    				else
    				{
    					[[SWCore instance] likeEvent:cellEvent];
    				}
    
    			}                      forControlEvents:UIControlEventTouchUpInside];
    		}
    
    		if (![cell.actionButton_2 bk_hasEventHandlersForControlEvents:UIControlEventTouchUpInside])
    		{
    			[cell.actionButton_2 bk_addEventHandler:^(id sender) {
    				@strongify(self);
    				@strongify(cell);
    
    				SWEvent *cellEvent = cell.event;
    
    				self.presentController = [SWMediaController controllerWithEvent:cellEvent];
    				[self.presentController addPhotoInController:self];
    			}                      forControlEvents:UIControlEventTouchUpInside];
    		}
    
    		if (![cell.actionButton_3 bk_hasEventHandlersForControlEvents:UIControlEventTouchUpInside])
    		{
    			[cell.actionButton_3 bk_addEventHandler:^(id sender) {
    				@strongify(self);
    				@strongify(cell);
    
    				SWEvent *cellEvent = cell.event;
    
    				[self performSegueWithIdentifier:@"commentsSegue" sender:cellEvent];
    			}                      forControlEvents:UIControlEventTouchUpInside];
    		}
    
    
    		if (![cell.actionButton_4 bk_hasEventHandlersForControlEvents:UIControlEventTouchUpInside])
    		{
    			[cell.actionButton_4 bk_addEventHandler:^(id sender) {
    				@strongify(self);
    				@strongify(cell);
    
    				SWEvent *cellEvent = cell.event;
    				self.presentController = [SWMediaController controllerWithEvent:cellEvent];
    				[self.presentController openPhotoBrowserInNavigationController:self.navigationController];
    			}                      forControlEvents:UIControlEventTouchUpInside];
    		}
    
    
    		if (![cell.nextButton bk_hasEventHandlersForControlEvents:UIControlEventTouchUpInside])
    		{
    			[cell.nextButton bk_addEventHandler:^(id sender) {
    				@strongify(self);
    				@strongify(cell);
    
    				SWEvent *cellEvent = cell.event;
    
    				[self performSegueWithIdentifier:@"eventControllerSegue" sender:cellEvent];
    
    			}                  forControlEvents:UIControlEventTouchUpInside];
    		}
    
    
    		return cell;
    	}

    Найдено в одном чужих из проектов. Призываем экспертов по говнокоду чтобы прокомментировать неочевидные решения автора и пролить свет на тайну этого метода

    shadeapps, 06 Апреля 2015

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