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

    −90

    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
    - (void)movementScreenUp
    {
        int shift;
        switch (_numberCell) {
            case 3:
                if (clickButtonGameCells.tag == 1 || clickButtonGameCells.tag == 10) {
                    shift = startPosition.y;
                    break;
                }
                if (clickButtonGameCells.tag == 2 || clickButtonGameCells.tag == 20) {
                    shift = - 50;
                    break;
                }
                if (clickButtonGameCells.tag == 3 || clickButtonGameCells.tag == 30) {
                    shift = - 90;
                    break;
                }
                
            case 4:
                if (clickButtonGameCells.tag == 1 || clickButtonGameCells.tag == 10) {
                    shift = startPosition.y;
                    break;
                }
                if (clickButtonGameCells.tag == 2 || clickButtonGameCells.tag == 20) {
                    shift = - 25;
                    break;
                }
                if (clickButtonGameCells.tag == 3 || clickButtonGameCells.tag == 30) {
                    shift = - 90;
                    break;
                }
                if (clickButtonGameCells.tag == 4 || clickButtonGameCells.tag == 40) {
                    shift = - 90;
                    break;
                }
                
            case 5:
                if (clickButtonGameCells.tag == 1 || clickButtonGameCells.tag == 10) {
                    shift = startPosition.y;
                    break;
                }
                if (clickButtonGameCells.tag == 2 || clickButtonGameCells.tag == 20) {
                    shift = - 1;
                    break;
                }
                if (clickButtonGameCells.tag == 3 || clickButtonGameCells.tag == 30) {
                    shift = - 40;
                    break;
                }
                if (clickButtonGameCells.tag == 4 || clickButtonGameCells.tag == 40) {
                    shift = - 86;
                    break;
                }
                if (clickButtonGameCells.tag == 5 || clickButtonGameCells.tag == 50) {
                    shift = - 86;
                    break;
                }
            
            case 6:
                if (clickButtonGameCells.tag == 1 || clickButtonGameCells.tag == 10) {
                    shift = startPosition.y;
                    break;
                }
                if (clickButtonGameCells.tag == 2 || clickButtonGameCells.tag == 20) {
                    shift = startPosition.y;
                    break;
                }
                if (clickButtonGameCells.tag == 3 || clickButtonGameCells.tag == 30) {
                    shift = - 2;
                    break;
                }
                if (clickButtonGameCells.tag == 4 || clickButtonGameCells.tag == 40) {
                    shift = - 52;
                    break;
                }
                if (clickButtonGameCells.tag == 5 || clickButtonGameCells.tag == 50) {
                    shift = - 105;
                    break;
                }
                if (clickButtonGameCells.tag == 6 || clickButtonGameCells.tag == 60) {
                    shift = - 105;
                    break;
                }
                
            default:
                break;
                 
        }
    
        [UIView animateWithDuration:0.25 animations:^{
            CGRect view_frame = self.frame;
            view_frame.origin = CGPointMake(self.frame.origin.x, shift);
            self.frame = view_frame;
        }];
    }

    Магия цифр

    tyler, 20 Января 2013

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

    −109

    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
    - (void)countDown
    {
        NSDate *currentDate = [NSDate date];
        NSTimeInterval timeInterval = ([currentDate timeIntervalSinceDate:startDate]);
        NSDate *timerDate = [NSDate dateWithTimeIntervalSince1970:timeInterval];
        NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
        [dateFormatter setDateFormat:@"ss"];
        [dateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0.0]];
        NSString *timeString=[dateFormatter stringFromDate:timerDate];
        
        if ([timeString isEqualToString:@"02"])
        {
            [logoTimer invalidate];
            logoTimer = nil;
            // some other code
        }
    }
    
    - (void)updateCounter
    {
        startDate = [NSDate dateWithTimeIntervalSinceNow:00];
        logoTimer = [NSTimer scheduledTimerWithTimeInterval:0.1
                                                     target:self
                                                   selector:@selector(countDown)
                                                   userInfo:nil
                                                    repeats:YES];
    }

    Вот так незатейливо можно поставить задержку на 2 секунды

    tyler, 19 Января 2013

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

    −107

    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
    -(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {	
    	return 6;
    }
    
    -(UITableViewCell *) tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
    	static NSString *kCellIdentifier = @"";
    	switch (indexPath.row) 
    	{
    		case 0:
    			kCellIdentifier = @"SpaceCell";
    			break;
    		case 1:
    			kCellIdentifier = @"LoginCell";
    			break;
    		case 2:
    			kCellIdentifier = @"PasswordCell";
    			break;
    		case 3:
    			kCellIdentifier = @"EmailCell";
    			break;
    		case 4:
    			kCellIdentifier = @"BirhtdayCell";
    			break;
    		default:
    			kCellIdentifier = @"ForgotCell";
    			break;
    	}
    	UITableViewCell *cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:kCellIdentifier] autorelease];
    	cell.selectionStyle = UITableViewCellSelectionStyleNone;
    	cell.backgroundColor = [UIColor clearColor];
    	cell.backgroundView.backgroundColor = [UIColor clearColor];
    
    	if (indexPath.row == 1)
    	{
    		[self backgroundCells:cell fileImage:@"top_downlayer.png"];
    		self.loginTextField.text = userName;
    		self.loginTextField.placeholder = @"User Name";
    		self.loginTextField.frame = CGRectMake(10.0f, 10.0f, 300.0f, 30.0f);
    		[cell.contentView addSubview:self.loginTextField];
    	}
    	else if (indexPath.row == 2)
    	{
    		[self backgroundCells:cell fileImage:@"middle_downlayer.png"];
    		self.passwordTextField.text = password;
    		self.passwordTextField.placeholder = @"Password";
    		self.passwordTextField.frame = CGRectMake(10.0f, 8.0f, 300.0f, 30.0f);
    		[cell.contentView addSubview:self.passwordTextField];
    	}
    	else if (indexPath.row == 3)
    	{
    		[self backgroundCells:cell fileImage:@"middle_downlayer.png"];
    		self.email.text = emailString;
    		self.email.placeholder = @"Email";
    		self.email.frame = CGRectMake(10.0f, 7.0f, 300.0f, 30.0f);
    		[cell.contentView addSubview:self.email];
    	}
    	else if (indexPath.row == 4)
    	{
    		[self backgroundCells:cell fileImage:@"middle_downlayer.png"];
    		UIImageView *inputIV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"input_login.png"]];
    		inputIV.frame = CGRectMake(20, 8, 280, 28);
    		[inputIV setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
    		[cell addSubview:inputIV];
    		[inputIV release];
    						
    		if (![resultsDate.text length])
    		{
    			UILabel *birhtdayLabel = [[UILabel alloc] initWithFrame:CGRectMake(29, 12, 150, 20)];
    			birhtdayLabel.text = @"Birthday";
    			[birhtdayLabel setTextAlignment:UITextAlignmentLeft];
    			[birhtdayLabel setFont: [UIFont fontWithName:@"Arial" size:17.0f]];
    			[birhtdayLabel setTextColor:[UIColor colorWithRed:0 green:0 blue:0 alpha:0.25]];
    			[birhtdayLabel setHighlightedTextColor:[UIColor whiteColor]];
    			[birhtdayLabel setBackgroundColor:[UIColor clearColor]];
    			[birhtdayLabel setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
    			[cell addSubview:birhtdayLabel];
    			[birhtdayLabel release];
    		}
    		else
    			[cell addSubview:resultsDate];
    	}
    	else if (indexPath.row == 5)
    	{
    		[self backgroundCells:cell fileImage:@"down_downlayer.png"];
    		UIImage *buttonBackgroundPressed = [UIImage imageNamed:@"search_btn_act.png"];
    		UIImage *buttonBackground = [UIImage imageNamed:@"search_btn.png"];
    		UIButton *singUpButton = [CustomButton buttonWithTitle:@"SIGN UP" target:self selector:@selector(singUpTouchAction:) frame:CGRectMake(20, 6, 280, 28) image:buttonBackground imagePressed:buttonBackgroundPressed];
    		singUpButton.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
    		singUpButton.autoresizingMask = UIViewAutoresizingFlexibleWidth;
    		[cell addSubview:singUpButton];
    	}
    	return cell;
    }

    Старый проект. Открыл класс наугад.

    Так кто-то строил форму для регистрации юзера. Каждое поле в форме - уникально.

    QuickNick, 14 Января 2013

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

    −113

    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
    -(void) reloadHelpMessage:(BOOL) _isPortrait
    {
        //ignoreDisappear = NO;
        //ingnoreWillAppear  = NO;
        if (_isPortrait)
        {
            helpMessage.frame = CGRectMake(helpMessage.frame.origin.x, helpMessage.frame.origin.y, self.view.bounds.size.width, 175);
            for (UIView* sub in [helpMessage subviews])
            {
                NSLog(@"__%@",[sub description]);
                switch (sub.tag) 
                {
                    case 1:
                        sub.frame = CGRectMake(68, 17, 200, 18);
                        break;
                    case 2:   
                        sub.frame = CGRectMake(68, 40, self.view.bounds.size.width - 70, 80);
                        break;
                    case 3:
                        sub.frame = CGRectMake(267, 3, 35, 29);
                        break;
                    case 4:
                        sub.frame = CGRectMake(10, 8, 48, 53);
                        break;
                    case 5:
                        sub.frame = CGRectMake(11, 128, roundf((self.view.bounds.size.width - 32)/2), 36);
                        break;
                    case 6:
                        sub.frame = CGRectMake(roundf((self.view.bounds.size.width/2) + 5), 128, roundf((self.view.bounds.size.width - 32)/2), 36);
                        break;
                   
                    default:
                        break;
                }   
            }
        }
        else
        {
            helpMessage.frame = CGRectMake(helpMessage.frame.origin.x, helpMessage.frame.origin.y, self.view.frame.size.width, 138);
            for (UIView* sub in [helpMessage subviews])
            {
                NSLog(@"__%@",[sub description]);
                switch (sub.tag) 
                {
                    case 1:
                        sub.frame = CGRectMake(68, 17, 200, 18);
                        break;
                    case 2:   
                        sub.frame = CGRectMake(68, 40, self.view.bounds.size.width - 80, 40);
                        break;
                    case 3:
                        sub.frame = CGRectMake(400, 3, 35, 29);
                        break;
                    case 4:
                        sub.frame = CGRectMake(10, 8, 48, 53);
                        break;
                    case 5:
                        sub.frame = CGRectMake(11, 91, roundf((self.view.bounds.size.width - 32)/2), 36);
                        break;
                    case 6:
                        sub.frame = CGRectMake(roundf((self.view.bounds.size.width/2) + 5), 91, roundf((self.view.bounds.size.width - 32)/2), 36);
                        break;
                    default:
                        break;
                }   
            }
        }
    }

    QuickNick, 14 Декабря 2012

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

    −105

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    if (resetPasswordAlert != nil)
    {
        resetPasswordAlert = nil, [resetPasswordAlert release];
    }
    [resetPasswordAlert release];
    resetPasswordAlert = [[ResetPasswordAlert alloc] init];

    Memory management по-белорусски...

    ZaR, 04 Декабря 2012

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

    −1050

    1. 1
    2. 2
    3. 3
    - (void) closeApp {
       int closer = 1 / 0;
    }

    Закрываем программу легкой арифметикой.
    Найдено в рабочем проекте.

    itruf, 25 Ноября 2012

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

    −91

    1. 1
    2. 2
    // synthesize viewController
    @synthesize viewController;

    Никогда еще комментарии не были столь информативны.

    tirinox, 22 Ноября 2012

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

    −98

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    #import <Foundation/Foundation.h>
     
    int main () {
        BOOL b1 = 71151208, b2 = 107155712;
        printf ("b1 is %s; b2 is %s.", (b1 ? "true" : "false"), (b2 ? "true" : "false"));
        return 0;
    }

    Ох, как же я эпично выстрелил себе в ногу.

    byss, 22 Ноября 2012

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

    −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
    - (void) setSavedData:(NSMutableDictionary *) chordsSettings
    {
    	if ([chordsSettings count]) 
        {
    		currentVariationsIndex = [[chordsSettings valueForKey:@"currentVariationsIndex"] intValue];
            pickerComponent0Row = [[chordsSettings valueForKey:@"pickerComponent0Row"] intValue];
            pickerComponent1Row = [[chordsSettings valueForKey:@"pickerComponent1Row"] intValue];
            canPlayString1 = [[chordsSettings valueForKey:@"canPlayString1"] boolValue];
            canPlayString2 = [[chordsSettings valueForKey:@"canPlayString2"] boolValue];
            canPlayString3 = [[chordsSettings valueForKey:@"canPlayString3"] boolValue];
            canPlayString4 = [[chordsSettings valueForKey:@"canPlayString4"] boolValue];
            canPlayString5 = [[chordsSettings valueForKey:@"canPlayString5"] boolValue];
            canPlayString6 = [[chordsSettings valueForKey:@"canPlayString6"] boolValue];
            lockedString1 = [[chordsSettings valueForKey:@"lockedString1"] boolValue];
            lockedString2 = [[chordsSettings valueForKey:@"lockedString2"] boolValue];
            lockedString3 = [[chordsSettings valueForKey:@"lockedString3"] boolValue];
            lockedString4 = [[chordsSettings valueForKey:@"lockedString4"] boolValue];
            lockedString5 = [[chordsSettings valueForKey:@"lockedString5"] boolValue];
            lockedString6 = [[chordsSettings valueForKey:@"lockedString6"] boolValue];
            chordPartOne = [[chordsSettings valueForKey:@"chordPart1"] retain];
            chordPartTwo = [[chordsSettings valueForKey:@"chordPart2"] retain];
    		flag = [[chordsSettings objectForKey:@"notes"] boolValue];
    	}
        else
        {
        	canPlayString1 = canPlayString2 = canPlayString3 = canPlayString4 = canPlayString5 = canPlayString6 = YES;
        	lockedString1 = lockedString2 = lockedString3 = lockedString4 = lockedString5 = lockedString6 = NO;
        	pickerComponent0Row = pickerComponent1Row = 0;
        	currentVariationsIndex = 0;
    		chordPartOne = @"C";
    		chordPartTwo = @"";
    		flag = NO;
    	}
    	chordPartThree = @"";
    }

    Интересно, если б аффтару нужно было писать приложение не для 6-струнной гитары, а для 12-струнной гитары или даже для арфы, он бы и там упорно не использовал массивы?

    QuickNick, 21 Ноября 2012

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

    −110

    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
    -(void) setEditing:(BOOL)editing animated:(BOOL)animate
    {
        if (indexDeleting != nil)
        {
            [[self.tableView cellForRowAtIndexPath:indexDeleting] willTransitionToState:UITableViewCellStateDefaultMask];
    //        if ([self.parentView.delegate sortArrayCount] /*dict array count*/ && [self.parentView.delegate editArrayCount:indexP.section]/*[[[dictArray objectAtIndex:section] valueForKey:@"edit"] count]*/)
    //        {
    //            [self.parentView.delegate setDeleteFlag:indexP value:@"0"];
    //        }        
        }
        indexDeleting = nil;
        isDeleting = NO;
        isEditing = editing;
    	[super setEditing:editing animated:animate];
    	
    	if (self.tableView.editing == editing)
    	{
    		[self.tableView setEditing:!editing animated:NO];
    	}
    	
    	[self.tableView setEditing:editing animated:animate];
    	[self.tableView reloadData];
    }

    По выражению парней, вынужденных поддерживать это месиво, "Это еще образец чистоты и элегантности".

    QuickNick, 20 Ноября 2012

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