Group Group Group Group Group Group Group Group Group

raywenderlich.com Forums

How To Make a Gesture-Driven To-Do List App Like Clear in Swift: Part 1/2

Learn how to make a gesture-driven to-do list app like Clear, complete with table view tricks, swipes, and pinches.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/2153-how-to-make-a-gesture-driven-to-do-list-app-like-clear-in-swift-part-1-2

Hi Audrey - I’m very exciting to try this app and I hope to soon; currently it builds clean but crashes at startup using xCode 7.2.1 and Swift 2.1.1.

The problem isn’t obvious to me, otherwise I’d post a solution!

Regards,

Michael

hi Michael! thanks for your question. When I open the finished sample in Xcode 7.2.1, update the settings, then run, I get lots of error flags and a couple of warnings about vars that should be lets. The error flags are mostly due to the change from method to property of tableView.visibleCells—lots of errors about removing the parentheses. When I fixed all the errors, it ran in the simulator.

Did you try the finished sample?

Hi Audrey,

Thankyou for sharing . it helped me and there is no document in internet for right swipe for Swift 2 and IOS 9. As there is an in built left swipe function.

But this works for both.

Hi Audrey, thank you for the nice tutorial. I learned a LOT about gradients and touch gestures from your work (I stopped at the left swipe deletions, and tried to apply the swiping to my own app.) Everything worked fine (your tutorial, and my code).

But I have a question… Your tutorial doesn’t use a prototype cell from the storyboard. AND you init() the cell with all the cell-level gradient code. All is well. But in my code, I do use a prototype cell from the storyboard (with two labels on it, with outlets into the table cell class).

My code runs fine with an empty cell class (no code or init(…) expressions in it all, just the two outlets. But when I tried to do your cell-level gradient tricks on my cell, the app crashes when it tried to configure the cell and write text into my two labels (that worked fine before the init(…) code that is required to add gradients to the cells.

Could you please comment (and hopefully state a solution) for adding gradients to prototype cells that have been configured on the storyboard? It’s a puzzle to me. I just put in empty initializers (two of them, the NScoder one is required), and it screws up initialization of the cells, so my outlets show up as nil in the table view controller. Thanks

hi Kevin: it seems to work if you put the gradient layer code directly into cellForRowAtIndexPath, although I couldn’t find a place to override layoutSubviews, and you should probably split out the static gradient code (let color1 … gradientLayer.locations…) into something that runs only once.

I think I found the problem. In order to have cell init()'s to work with storyboard cells, I had to call super.init inside of the NSCoder required init. That seemed to work fine.

The sample project appears to crash at launch now under 7.3.

hi when i am executing the the program part by part for the check point (6) i am getting a error can any one say some solution at

let textSize = text!.sizeWithAttributes([NSFontAttributeName:font]) error:fatal error: unexpectedly found nil while unwrapping an Optional value IN the class StrikeThroughText

can any one solve this @audrey

thanks for posting! in addition to the “convert to latest Swift” fixes, this works:

func resizeStrikeThrough() {
  if let text = text {
    let textSize = text.sizeWithAttributes([NSFontAttributeName:font])
    strikeThroughLayer.frame = CGRect(x: 0, y: bounds.size.height/2,
        width: textSize.width, height: kStrikeOutThickness)
  }
}

if it’s the same error as nishanthgolla’s, see my reply about resizeStrikeThrough().

THANK YOU THANK YOU @audrey

I built and ran this on my iPhone 6, but for some reason it appears as iPhone 5 sized on my screen…anyone have any ideas? Thanks!

actually, it’s displaying as 4s, even in larger simulators

Reveal shows a system-generated constraint on the UIView: height=480

I think it’s a bug in the latest Xcode.

I’m back: I wrote a simpler version—table view with default table view cell, String content: the system-generated height constraint is 736 for iPhone 6s Plus simulator. So there’s something about the fancy table view cell that’s causing the problem…

Hi,

I am new to all this coding excitement, and have started to build my first app. I am currently trying to build a to do style list as per this tutorial as it is just what I wanted and your tutorial appeared the most comprehensive I could find.

However, I am having a really frustrating issue.

I have a number of views already in use so I have created a new tableView and new ViewController to connect to it. However, right at the outset I need to connect the two to create the outlet. I simply cannot get the ctrl + drag to connect to the ViewController and generate the @IBOutlet. In fact only a selection of my storyboard views will connect to any of my controllers.

Maybe I am missing something and I am sure that there is a degree of rookie-ism here, but I have searched everywhere for a reason and just cannot find one.

Please help someone - I hate the thought of failing at the first hurdle…

Hi Audrey Great Tutorial

But any adjustments ? It is possible to delete all cells when the app is running.
And you would not be able to add any task.

So would there be a plus+button at least so you can make another cell/ task in the running app?

Also how to fix the black top and bottom?

I’m very sorry I missed seeing this, back in July!

Did you set the Class of your new view controller, in the identity inspector? See example screenshot below.

Xcode might need a nudge (Product\Clean) but the assistant editor should show your new view controller file under Automatic.

IB won’t make connections to a code file that’s showing under Manual.

even when there are no cells, you can pull down, and a new cell will appear

I haven’t found a solution for the system setting the size to 4s/se, although someone said he found a fix. I’ll ask him tonight, at Cocoaheads.

I updated the project to Xcode beta 5 and the problem is still there

This tutorial is more than six months old so questions are no longer supported at the moment for it. We will update it as soon as possible. Thank you! :]