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

    −98

    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
    -(UIImage*) getImageForDigit:(int)value
    {
    	UIImage *img = nil;
    	
    	switch (value)
    	{
    		case -1:
    		{
    			img = [UIImage imageNamed:@"beat_0_off.png"];
    			break;
    		}
    		case 0:
    		{
    			img = [UIImage imageNamed:@"beat_0.png"];
    			break;
    		}
    		case 1:
    		{
    			img = [UIImage imageNamed:@"beat_1.png"];
    			break;
    		}
    		case 2:
    		{
    			img = [UIImage imageNamed:@"beat_2.png"];
    			break;
    		}
    		case 3:
    		{
    			img = [UIImage imageNamed:@"beat_3.png"];
    			break;
    		}
    		case 4:
    		{
    			img = [UIImage imageNamed:@"beat_4.png"];
    			break;
    		}
    		case 5:
    		{
    			img = [UIImage imageNamed:@"beat_5.png"];
    			break;
    		}
    		case 6:
    		{
    			img = [UIImage imageNamed:@"beat_6.png"];
    			break;
    		}
    		case 7:
    		{
    			img = [UIImage imageNamed:@"beat_7.png"];
    			break;
    		}
    		case 8:
    		{
    			img = [UIImage imageNamed:@"beat_8.png"];
    			break;
    		}
    		case 9:
    		{
    			img = [UIImage imageNamed:@"beat_9.png"];
    			break;
    		}
    		default:
    		{
    			break;
    		}
    	}
    	
    	return img;
    }

    Ученица отрыла простановку цифр на "кагбэ жидкокристаллический" дисплей.

    QuickNick, 06 Октября 2012

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

    −97

    1. 1
    2. 2
    NSMutableDictionary* data = [[NSMutableDictionary alloc] initWithObjectsAndKeys:@"Заголовок", @"name",  
    @"Очень длинное описание акции, которое надо для проверки функционирования элементов прекрасного пользовательского интерфейса, работающего на последнем издыхании. Казалось бы, что такого поправить две кнопки. Но нет, тут никто не знает про MVC", @"description", nil];

    Тестовые данные в проекте

    GK2012, 21 Сентября 2012

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

    −95

    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
    - (void)awakeFromNib
    { 
        // ...
        [[_contextMenu itemAtIndex:0] setTitle:NSLocalizedString(@"ContextMenuItem1Caption", nil)];
        [[_contextMenu itemAtIndex:1] setTitle:NSLocalizedString(@"ContextMenuItem2Caption", nil)];
        [[_contextMenu itemAtIndex:2] setTitle:NSLocalizedString(@"ContextMenuItem3Caption", nil)];
        [[_contextMenu itemAtIndex:3] setTitle:NSLocalizedString(@"ContextMenuItem4Caption", nil)];
        [[_contextMenu itemAtIndex:4] setTitle:NSLocalizedString(@"ContextMenuItem5Caption", nil)];
        [[_contextMenu itemAtIndex:5] setTitle:NSLocalizedString(@"ContextMenuItem6Caption", nil)];
        [[_contextMenu itemAtIndex:6] setTitle:NSLocalizedString(@"ContextMenuItem7Caption", nil)];
        [[_contextMenu itemAtIndex:8] setTitle:NSLocalizedString(@"ContextMenuItem8Caption", nil)];
        [[_contextMenu itemAtIndex:10] setTitle:NSLocalizedString(@"ContextMenuItem9Caption", nil)];
        [[_contextMenu itemAtIndex:11] setTitle:NSLocalizedString(@"ContextMenuItem10Caption", nil)];
        [[_contextMenu itemAtIndex:13] setTitle:NSLocalizedString(@"ContextMenuItem11Caption", nil)];
        [[[[_contextMenu itemAtIndex:13] submenu] itemAtIndex:0] setTitle:NSLocalizedString(@"ContextMenuItem11-1Caption", nil)];         // submenu notices
        [[[[_contextMenu itemAtIndex:13] submenu] itemAtIndex:1] setTitle:NSLocalizedString(@"ContextMenuItem11-2Caption", nil)];
        [[[[_contextMenu itemAtIndex:13] submenu] itemAtIndex:2] setTitle:NSLocalizedString(@"ContextMenuItem11-3Caption", nil)];
        [[[[_contextMenu itemAtIndex:13] submenu] itemAtIndex:3] setTitle:NSLocalizedString(@"ContextMenuItem11-4Caption", nil)];
        [[[[_contextMenu itemAtIndex:13] submenu] itemAtIndex:4] setTitle:NSLocalizedString(@"ContextMenuItem11-5Caption", nil)];
        [[[[_contextMenu itemAtIndex:13] submenu] itemAtIndex:5] setTitle:NSLocalizedString(@"ContextMenuItem11-6Caption", nil)];
        [[[[_contextMenu itemAtIndex:13] submenu] itemAtIndex:6] setTitle:NSLocalizedString(@"ContextMenuItem11-7Caption", nil)];
        [[[[_contextMenu itemAtIndex:13] submenu] itemAtIndex:7] setTitle:NSLocalizedString(@"ContextMenuItem11-8Caption", nil)];
        [[_contextMenu itemAtIndex:14] setTitle:NSLocalizedString(@"ContextMenuItem12Caption", nil)];
        [[[[_contextMenu itemAtIndex:14] submenu] itemAtIndex:0] setTitle:NSLocalizedString(@"ContextMenuItem12-1Caption", nil)];
        [[[[_contextMenu itemAtIndex:14] submenu] itemAtIndex:1] setTitle:NSLocalizedString(@"ContextMenuItem12-2Caption", nil)];
        [[[[_contextMenu itemAtIndex:14] submenu] itemAtIndex:3] setTitle:NSLocalizedString(@"ContextMenuItem12-3Caption", nil)];
        [[_contextMenu itemAtIndex:16] setTitle:NSLocalizedString(@"ContextMenuItem13Caption", nil)];
        [[_contextMenu itemAtIndex:17] setTitle:NSLocalizedString(@"ContextMenuItem14Caption", nil)];
        [[_contextMenu itemAtIndex:18] setTitle:NSLocalizedString(@"ContextMenuItem15Caption", nil)];
        [[_contextMenu itemAtIndex:19] setTitle:NSLocalizedString(@"ContextMenuItem16Caption", nil)];
        [[_contextMenu itemAtIndex:20] setTitle:NSLocalizedString(@"ContextMenuItem17Caption", nil)];
        [[_contextMenu itemAtIndex:21] setTitle:NSLocalizedString(@"ContextMenuItem18Caption", nil)];
        
        [[_contextMenu2 itemAtIndex:0] setTitle:NSLocalizedString(@"ContextMenuItem1", nil)];
        [[_contextMenu2 itemAtIndex:1] setTitle:NSLocalizedString(@"ContextMenuItem2", nil)];
        [[_contextMenu2 itemAtIndex:3] setTitle:NSLocalizedString(@"ContextMenuItem3", nil)];
        [[_contextMenu2 itemAtIndex:4] setTitle:NSLocalizedString(@"ContextMenuItem4", nil)];
        [[_contextMenu2 itemAtIndex:5] setTitle:NSLocalizedString(@"ContextMenuItem5", nil)];
        [[_contextMenu2 itemAtIndex:7] setTitle:NSLocalizedString(@"ContextMenuItem6", nil)];
        [[_contextMenu2 itemAtIndex:8] setTitle:NSLocalizedString(@"ContextMenuItem7", nil)];
        // ...
    }

    Метод локализации пунктов меню.
    Весьма оригинальный.

    glook, 03 Сентября 2012

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

    −102

    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
    -(void)tableView:(UITableView*)tableViewTable didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
        switch (indexPath.row) {
            case 0:
            {
                ViewControllerFavorites *contoller = [[ViewControllerFavorites alloc] initWithNibName:nil bundle:nil];
                [contoller setNavigationController:navigationController];
                [navigationController pushUIViewController:contoller WithName:[[[row getData] objectForKey:@"description"] uppercaseString]];
            }
                break;
            case 1:
            {
                ViewControllerMyAccount *contoller = [[ViewControllerMyAccount alloc] initWithNibName:nil bundle:nil];
                [contoller setNavigationController:navigationController];
                [navigationController pushUIViewController:contoller WithName:[[[row getData] objectForKey:@"description"] uppercaseString]];            
            }
                break;            
            case 2:
            {
                ViewControllerParts *contoller = [[ViewControllerParts alloc] initWithNibName:nil bundle:nil];
                [contoller setNavigationController:navigationController];
                [navigationController pushUIViewController:contoller WithName:[[[row getData] objectForKey:@"description"] uppercaseString]];            
            }
                break;            
            case 3:
            {
                ViewControllerFinancing *contoller = [[ViewControllerFinancing alloc] initWithNibName:nil bundle:nil];
                [contoller setNavigationController:navigationController];
                [navigationController pushUIViewController:contoller WithName:[[[row getData] objectForKey:@"description"] uppercaseString]];            
            }
                break;            
            case 4:
            {
                ViewControllerWebView *contoller = [[ViewControllerWebView alloc] initWithNibName:nil bundle:nil link:@"http://www.facebook.com"];
                [contoller setNavigationController:navigationController];
                [navigationController pushUIViewController:contoller WithName:[[[row getData] objectForKey:@"description"] uppercaseString]];    
            }
                break;            
            case 5:
            {
                ViewControllerWebView *contoller = [[ViewControllerWebView alloc] initWithNibName:nil bundle:nil link:@"http://twitter.com"];
                [contoller setNavigationController:navigationController];
                [navigationController pushUIViewController:contoller WithName:[[[row getData] objectForKey:@"description"] uppercaseString]]; 
            }
                break;            
            case 6:
            {
                ViewControllerWebView *contoller = [[ViewControllerWebView alloc] initWithNibName:nil bundle:nil link:@"http://plus.google.com"];
                [contoller setNavigationController:navigationController];
                [navigationController pushUIViewController:contoller WithName:[[[row getData] objectForKey:@"description"] uppercaseString]]; 
            }
                break;            
            case 7:
            {
                ViewControllerLiveChat *contoller = [[ViewControllerLiveChat alloc] initWithNibName:nil bundle:nil];
                [contoller setNavigationController:navigationController];
                [navigationController pushUIViewController:contoller WithName:[[[row getData] objectForKey:@"description"] uppercaseString]];           
            }
                break;            
            case 8:
            {
                ViewControllerGasStations *contoller = [[ViewControllerGasStations alloc] initWithNibName:nil bundle:nil];
                [contoller setNavigationController:navigationController];
                [navigationController pushUIViewController:contoller WithName:[[[row getData] objectForKey:@"description"] uppercaseString]];            
            }
                break;            
            case 9:
            {
                ViewControllerVinScanner *contoller = [[ViewControllerVinScanner alloc] initWithNibName:nil bundle:nil];
                [contoller setNavigationController:navigationController];
                [navigationController pushUIViewController:contoller WithName:[[[row getData] objectForKey:@"description"] uppercaseString]];           
            }
                break;            
            case 10:
            {
                ViewControllerQRScanner *contoller = [[ViewControllerQRScanner alloc] initWithNibName:nil bundle:nil];
                [contoller setNavigationController:navigationController];
                [navigationController pushUIViewController:contoller WithName:[[[row getData] objectForKey:@"description"] uppercaseString]];            
            }
                break;            
            case 11:
            {
                ViewControllerNewsletter *contoller = [[ViewControllerNewsletter alloc] initWithNibName:nil bundle:nil];
                [contoller setNavigationController:navigationController];
                [navigationController pushUIViewController:contoller WithName:[[[row getData] objectForKey:@"description"] uppercaseString]];            
            }
                break;            
            case 12:
           {
                ViewControllerSettings *contoller = [[ViewControllerSettings alloc] initWithNibName:nil bundle:nil];
                [contoller setNavigationController:navigationController];
                [navigationController pushUIViewController:contoller WithName:[[[row getData] objectForKey:@"description"] uppercaseString]];           
            }
                break;        
            default:
                break;
        }

    Вот так в коммерческих проектах реализуют навигацию.

    GK2012, 23 Августа 2012

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

    −99

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    // WTF is 8.5? Oo I will never, ever hardcode some random values.
    	linkStatusImage.frame = CGRectMake (5, height / 2 - 8.5, 17, 17);
    	descriptionLabel.frame = CGRectMake (27, 5, width - 32 - rightMargin, 20);
    	authorLabel.frame = CGRectMake (27, 30, width - 32 - rightMargin, 20);
    	addressLabel.frame = CGRectMake (27, 55, width - 32 - rightMargin, height - 60);
    	separatorImage.frame = CGRectMake (0, height - 2, separatorImage.image.size.width, 2);
    	favButton.frame = CGRectMake (width - 22, height / 2 - 8.5, 17, 16);

    byss, 23 Августа 2012

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

    −89

    1. 1
    if (numberOfAnimals == 3 || numberOfAnimals == 3)

    "Чтоб наверняка"
    Новичок нашел заказчика. Дал мне код, чтобы я сделал "чтобы работал". Начал смотреть, ужаснулся.

    itruf, 19 Августа 2012

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

    −99

    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
    - (void)selectCurrentItem
    {
        NSInteger index = 0;
        BOOL fl = NO;
        BOOL fl2 = YES;
        BOOL fl3 = YES;
        
        if (self.currentScheme == LeftPanelSchemeFriendsDetail) {
            if (!self.selectedGenre) {
                fl3 = NO;   
            } else {
                fl3 = YES;
            }
        }
        
        if (!self.selectCurrentItemOnes) {
            self.needShowFriendsDetail = NO;
        }
        
        if (self.selectedItem && (self.needSelectCurrentItem || !self.selectCurrentItemOnes) && fl3) {
            if ([self.news containsObject:self.selectedItem]) {
                index = [self.news indexOfObject:self.selectedItem];
                if ([self.news containsObject:self.selectedItem]) {
                    if (index == [self.news indexOfObject:self.selectedItem]) {
                        fl = YES;
                        
                        if (self.currentScheme == LeftPanelSchemeFriendsMap) {
                            self.needShowFriendsDetail = NO;
                            
                            if (self.downButton.enabled) {
                                self.needShowFriendsDetail = NO;
                                [self updateDownPressed];
                                fl2 = NO;
                            } else {
                                
                            }
                            
                        } 
                    }
                }
            }
        }
        if ([self.tableView numberOfRowsInSection:0] && fl2) {
            [self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:index inSection:0] animated:YES scrollPosition:UITableViewScrollPositionMiddle];
            [self selectRowAtIndexPath:[NSIndexPath indexPathForRow:index inSection:0]];
            if (fl) {
                self.selectCurrentItemOnes = YES;
                fl = NO;
            }
        }
    }

    shoumikhin, 13 Августа 2012

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

    −108

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    - (void)setValue:(NSString *)value
    {
        if(value != _value)
        {
            [_value release];
            
            if (value)
                 _value = [value retain];
        }
    
    //Тут всякие действия еще
    }

    Седьмая строка просто убила, делаем setValue:nil и в _value у нас указатель на мусор

    notxcain, 23 Июля 2012

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

    −95

    1. 1
    2. 2
    NSString *currentElementValue = ...;
    int status = [[[currentElementValue copy] autorelease] intValue];

    Кто плохо понимает как работает пямять на стеке

    notxcain, 20 Июля 2012

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

    −101

    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
    -(void)showRetrySuccess:(NSString*)requestUrlString
    {
    	NSString *statusMessage = @"";
    	
    	if([requestUrlString rangeOfString:kFollowFriendsRequest].location != NSNotFound)
    	{
    		statusMessage =@"Your follow friend request completed successfully.";
    	}
    	else
    		if([requestUrlString rangeOfString:kUnfollowFriendsRequest].location != NSNotFound)
    		{
    			statusMessage =@"Your unfollow friend request completed successfully.";
    		}else
    			if([requestUrlString rangeOfString:kDeleteContentService].location != NSNotFound)
    			{
    				statusMessage =@"Your delete request completed successfully.";
    			}else
    				if([requestUrlString rangeOfString:kSavePostService].location != NSNotFound)
    				{
    					statusMessage =@"Your save post request completed successfully";
    				}else
    					if([requestUrlString rangeOfString:kSaveMediaService].location != NSNotFound)
    					{
    						statusMessage =@"Your save request  completed successfully";
    					}else
    						if([requestUrlString rangeOfString:kSaveTwitterDirectMessage].location != NSNotFound)
    						{
    							statusMessage =@"Your request completed successfully.";
    						}else
    							if([requestUrlString rangeOfString:kSaveTwitterResponse].location != NSNotFound)
    							{
    								statusMessage =@"Your request completed successfully.";
    							}
    							else
    								if([requestUrlString rangeOfString:kAddCommentService].location != NSNotFound)
    								{
    									statusMessage =@"Your post comment request completed successfully.";
    								}
    	UIAlertView * alert = [[[UIAlertView alloc] initWithTitle:@"" message:statusMessage delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]autorelease];
    	[alert show];
    	
    	
    }

    GLvRzZZ, 13 Июля 2012

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