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

    Всего: 3

  2. Swift / Говнокод #24592

    +1

    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
    // NextViewController.swift
    
    override func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!) {
        NSUserDefaults.standardUserDefaults().setInteger(indexPath.row, forKey: "Selected offense")
    		
        let offense: NSDictionary = self.offenses.objectAtIndex(indexPath.row) as NSDictionary
        let id: Int = offense.objectForKey("id") as Int
        let title: String = offense.objectForKey("title") as String
        NSUserDefaults.standardUserDefaults().setInteger(id, forKey: "Selected offense id")
        NSUserDefaults.standardUserDefaults().setObject(title, forKey: "Selected offense title")
    }
    
    // PreviousViewController.swift
    
    override func viewDidAppear(animated: Bool) {
        super.viewDidAppear(animated)
        hideKeyboard()
        tableView.reloadData()
    }
    	
    func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
        let kCellIndetifier: String = "NewOffenseCell"
        var cell: UITableViewCell = tableView.dequeueReusableCellWithIdentifier(kCellIndetifier, forIndexPath: indexPath) as UITableViewCell
    		
        if cell == nil {
            cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: kCellIndetifier)
        }
    		
        cell.text = NSUserDefaults.standardUserDefaults().stringForKey("Selected offense title")
        cell.font = UIFont.systemFontOfSize(20)
        return cell
    }

    Реализуем колбэки *лицорука*

    def, 06 Августа 2018

    Комментарии (95)
  3. Swift / Говнокод #24591

    0

    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
    func createCrossForRemovingImage() {
    		var firstCrossView: UIImageView = UIImageView(frame: CGRectMake(90, -10, 30, 30))
    		firstCrossView.layer.cornerRadius = 15
    		firstCrossView.image = UIImage(named: "Cross")
    		firstCrossView.tag = 200
    		firstCrossView.userInteractionEnabled = true
    		firstCrossView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: "removeImage:"))
    		firstCrossView.hidden = true
    		
    		var secondCrossView: UIImageView = UIImageView(frame: CGRectMake(90, -10, 30, 30))
    		secondCrossView.layer.cornerRadius = 15
    		secondCrossView.image = UIImage(named: "Cross")
    		secondCrossView.tag = 200
    		secondCrossView.userInteractionEnabled = true
    		secondCrossView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: "removeImage:"))
    		secondCrossView.hidden = true
    		
    		var thirdCrossView: UIImageView = UIImageView(frame: CGRectMake(90, -10, 30, 30))
    		thirdCrossView.layer.cornerRadius = 15
    		thirdCrossView.image = UIImage(named: "Cross")
    		thirdCrossView.tag = 200
    		thirdCrossView.userInteractionEnabled = true
    		thirdCrossView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: "removeImage:"))
    		thirdCrossView.hidden = true
    		
    		var fourthCrossView: UIImageView = UIImageView(frame: CGRectMake(90, -10, 30, 30))
    		fourthCrossView.layer.cornerRadius = 15
    		fourthCrossView.image = UIImage(named: "Cross")
    		fourthCrossView.tag = 200
    		fourthCrossView.userInteractionEnabled = true
    		fourthCrossView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: "removeImage:"))
    		fourthCrossView.hidden = true
    		
    		firstImageView.addSubview(firstCrossView)
    		secondImageView.addSubview(secondCrossView)
    		thirdImageView.addSubview(thirdCrossView)
    		fourthImageView.addSubview(fourthCrossView)
    	}

    Когда-то я это написал Оо

    def, 06 Августа 2018

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

    −366

    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
    NSError* utilitiesCheckEmail(NSString* string)
    {
        NSInteger email_symbol_count=0;
        NSInteger pos_email_symbol=0;
        NSInteger pos_point=0;
        NSInteger count=string.length;
    
        
        if(count!=0)
        {
            unichar buffer[count];
        
            [string getCharacters:buffer];
            
            for(NSInteger i=0;i<count;i++)
            {
                unichar ch=buffer[i];
                
                if( !( (ch>='a') && (ch<='z') ) &&  !( (ch>='A') && (ch<='Z') ) && !( (ch>='0') && (ch<='9') ) && (ch!='_') && (ch!='-') )
                {
                    switch (ch)
                    {
                        case '@':
                        {
                            email_symbol_count++;
                            pos_email_symbol=i;
                            
                            break;
                        }
                            
                        case '.':
                        {
                            pos_point=i;
                            break;
                        }
                            
                        default:
                            return [NSError errorWithDomain:NULL error:eErrorEmailInvalidFormat];
                    }
                }
            }
            
            if(  (email_symbol_count==1) && (pos_point!=0) && (pos_point>pos_email_symbol) && ((pos_point+1)<count) )
                return NULL;
        }
        
        return [NSError errorWithDomain:NULL error:eErrorEmailInvalidFormat];
    }

    Валидируем email

    def, 25 Января 2016

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