Category Archives: Creative & Tech

Creative & Tech

Upgrading swift version

Today I tried to upgrade developing iOS APP for personal use. Actually I have not been updating it for 1 year. Last file update was 6th Jan 2016. since i was free during end year holiday, looks tried to make App by swift 2.0. just coming same season. So latest version for swift is 3.0.

I’m aware of some updated function and different function, those issue was fixed. But crashing on simulated was happened even if there is no complier error on Xcode. after checking line by line, I detected error was occured when App tried to get permission to access Calendar data by Using EKEventStore. One addtionall setting for info.plist is needed due to privacy policy changing by apple.

Info.plist – Requesting Permission Privacy Settings in iOS 10.

App Crash was solved, but I spent 3 hours to detect it…. more effort to understand is needed…

Creative & Tech

Custom UITableViewCell without Storyboard

I was looking for the way to make List function based on UITableView be directly editable text field. UITableView also offer editable by swipe function. But I wanted to make function to directly edit lists on UITableView. To make sure that, Custom UITableViewCell is needed, if without StoryBoard. Btw I prefer to generate content without using StoryBoard, it means my application completely depends on source code. 

Step 1: To make new class “CustomTableViewCell” by inheriting “UITableViewCell”.

class CustomTableViewCell: UITableViewCell{
    
    let TitleArea: UITextField = UITextField(frame: CGRect(x: 30, y: 5, width: 350, height: 25))
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String!)
    {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        TitleArea.delegate = self
        contentView.addSubview(TitleArea)
    }
    
    override func setSelected(selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
    }
    
    required init(coder aDecoder: NSCoder)
    {
        super.init(coder: aDecoder)!
    }    
}

and to implement this custom class without StoryBoard, most important thing is to define it on “TableView.registerClass” and “return value of UITableViewCell. Please refer below highlited line in sample source code.

class CustomViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
    
    var CusotmTableView: UITableView = UITableView()
	
    override func viewDidLoad() {
        super.viewDidLoad()
            
        // Get width and height of view.
        let displayWidth: CGFloat = self.view.frame.width
        let displayHeight: CGFloat = self.view.frame.height
        
        // Generate TableView
        CusotmTableView.frame = CGRect(x: 0, y: barHeight+30, width: displayWidth, height: displayHeight  )
        
        // [Important] To designate Custom UITableViewcells as UITableViewCell
        CusotmTableView.registerClass(CustomTableViewCell.self, forCellReuseIdentifier: "MyCell")
        
	CusotmTableView.dataSource = self
        CusotmTableView.delegate = self
        
        self.view.addSubview(CusotmTableView)
        

    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()

    }
	
    func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        return ******
    }
    
    func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
        return "title"
    }
    
    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return section
    }
    
    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        
        //CustomCell
        let cell:  CustomTableViewCell = tableView.dequeueReusableCellWithIdentifier("MyCell", forIndexPath: indexPath) as! CustomTableCell
        cell.delegate = self
        
        return cell
    }
   
}

If you want to generate Custom UITableViewCell by source code without StoryBorder, Please make sure these two points. 

Creative & Tech

SubThread for UIView Control

I’m continually developing original reminder’s app. I faced one issue when showing content on view. After got reminder’s data from EventStore, tried to put it as UITextView to confirm what kind reminders we can retrieve. But UITextView has error with following message.

This application is modifying the autolayout engine from a background thread, which can lead to engine corruption and weird crashes. This will cause an exception in a future release.

This was caused by multi thread processing. Some process to display reminder text into UITextFiled after get reminder data was contained in closure of function to retrieve reminder data from EventStore with identifier. Those process was called per identifier, it means in case of multi reminder list which the device has. Then each processes to modify UITextField were in subthread.  

As solution for this, I implemented “Dispatch_sync” method by referring to Grand Central Dispatch (GCD) Reference

dispatch_sync(dispatch_get_main_queue(),
            {
                self.textfiled.text = "Sample text to show text from subthread."
            })

It was success without any error. I could learn one new thing for iOS at this time.

Creative & Tech

EKSource

This is my note about iOS Application development which is originally managing event data ( Calendar or Reminder) to make sure be more easy UI for me.

To get Calendar or Reminder List from iOS device, EKEventStore class is basement to access to those database. And in that data base there are some datasource. EKSource class contains data source definition like “iCloud”, “Default”, 

EKSource.title(String) SourceType Memo
Default Local  
Other ??  
Subscribed Calendar Subscribed  
iCloud CalDAV  

These definition might work for permission to read & write the event. I will keep to investigate it.

 

 

Creative & Tech

Floppy Save Icon

Just considering iOS App UI as private by referring internet. I found one topic about save icon. On smartphone app, basically autosave function should be required to make sure good usability without save icon and consciousness for saving. But some case, explicit saving by themselves is the best way to save the date since user can store historical works.

20151225saveicon I noticed almost applications have “Floppy Disk” Save icon. But Floppy Disk had been abolished for 10 years. Younger generation doesn’t know the meaning of Floppy, don’t have any experience to save data into Floppy Disk. Althought almost user can easily understand and operate to save date by clicking the Floppy Disk Icon. Needless to write, older user well remembers the sound when Floppy drive is working.

These situation makes me understand that the floppy icon doesn’t mean Floppy itself at this time, it’s function to save. I’ m not sure it’s easy to recognize the meaning of icon for younger generation who have not used Floppy Disk, but they have got the meaning without realizing. That’s very curious.