Category Archives: Creative & Tech

Creative & Tech Diary

Started to write note.mu

Note.mu is a kind of the blog service in japan. By looking into functionality on the service, it’s just blog service. But concept and basic physophy is totally different from typical blog service. Most blog services are generating revenue from ads. But this service is not considering to just increasing traffic or PV. They are empowermenting creators by supporting to charge contents. There are many type of usage as creator. The simplest case is just selling article by monthly charge or one time. Another case is collecting monthly fee for fun club by proving article news or contents.

I’m not thinking to sell my articles so far. But if I will be able to make more valuable content or article, it’s easy to start to sell rather than publishing e-books or promoting my content to publisher. I’m looking forward to seek my possibility by continually using this platform.

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.