Posts tagged #iOS 8

Return Type Error Messages are Wrong in Swift

Error messages from Xcode have a tendency to be wrong. A bad error message can send you searching in the dark in the wrong direction.

I want to share my process for searching for answers using Google and strategies that you can leverage in code to help you overcome some obstacles with Swift’s error prone error messages.

It seems that I find more wrong error message in Swift than from my experiences with Objective-C. However, that could also be attributed to my ability to fix common errors before Xcode had time to tell me what it thought was wrong in Objective-C.

I do know that I learn the most when I encounter errors and figure out how to fix them. As a beginner programmer, you will need to start identifying errors as you type them, or after Xcode points out an error message.

I’ll show an example using an error message that had me stumped, until I revisited it the next day.

Swift Compiler Error

/Users/paulsolt/Downloads/Word Magnet/Word Magnet/ViewController.swift:173:12: Cannot invoke 'init' with an argument list of type '(x: $T4, y: $T9)'

Code

func randomInt(number: Int) -> Int {
    return Int(arc4random_uniform(UInt32(number)))
}

func randomInt(number: CGFloat) -> Int {
    return Int(arc4random_uniform(UInt32(number)))
}

func randomPointInRectangle(rectangle: CGRect) {
    // Attempt 1
    return CGPoint(x: randomInt(rectangle.size.width), y: randomInt(rectangle.size.height))
} 

Ok, can you guess what’s wrong?

Google to the Rescue

I didn’t find the error message helpful, so I resorted to Googling it. Search the error message, and remove the file path and line numbers.
You can open the Issue Navigator and then right-click on an error to copy the error message to a web search bar.

Search 1

Cannot invoke 'init' with an argument list of type '(x: $T4, y: $T9)’

Nothing sticks out to me on this first search. I see MIPS assembly results from the $T4 and $T9, which look like hardware registers from assembly language. That won’t help you.

Search 2
Some of the error message is error specific, and doesn’t search well. Let’s cleanup the search text.

  1. You’ll need to remove the uniquely identifying information highlighted in bold. 
  2. Add Swift to the front of the search term. 
  3. Remove the single quotes.
Cannot invoke 'init' with an argument list of type '(x: $T2, y: $T5)’

becomes

Swift + Cannot invoke with an argument list of type (x: , y: )

The first result is good, but it’s not going to help us. It’s not the real problem that you have here. The first result is actually related to the reason I started writing this code.

http://stackoverflow.com/questions/24108827/swift-numerics-and-cgfloat-cgpoint-cgrect-etc

With two searches and you are still not understanding what is wrong. That’s normal when you first start programming. The results we found are relating to mixing Double, Int, and CGFloat types together, but that’s not the problem we’re facing.

What to do when Google Fails?

Next step when I have an issue like this is to try rewriting the line of code in a different way. You can write code that’s more verbose and that does less work on a single line of code. Separate complex statements into a separate lines of code.

Make a hypothesis and test it

Maybe there is something wrong with the randomInt() function, lets use just a number.

Workflow Tip

  1. Copy and paste the offending line of code.
  2. Comment out the first line, and alter the second line of code.

Swift Compiler Error

/Users/paulsolt/Downloads/Word Magnet/Word Magnet/ViewController.swift:174:12: Cannot invoke 'init' with an argument list of type '(x: IntegerLiteralConvertible, y: IntegerLiteralConvertible)'

Code

func randomInt(number: Int) -> Int {
    return Int(arc4random_uniform(UInt32(number)))
}

func randomInt(number: CGFloat) -> Int {
    return Int(arc4random_uniform(UInt32(number)))
}

func randomPointInRectangle(rectangle: CGRect) {
    // Attempt 2
    //    return CGPoint(x: randomInt(10), y: randomInt(10))
    return CGPoint(x: 10, y: 10)
} 

The error message is a little different, but very similar. Swift is still having an issue with the init method for the CGPoint. 

Break apart lines of code into multiple steps

What happens when you separate the CGPoint initialization from the return statement?

Swift Compiler Error

/Users/paulsolt/Downloads/Word Magnet/Word Magnet/ViewController.swift:176:12: 'CGPoint' is not convertible to '()'

Code

func randomInt(number: Int) -> Int {
    return Int(arc4random_uniform(UInt32(number)))
}

func randomInt(number: CGFloat) -> Int {
    return Int(arc4random_uniform(UInt32(number)))
}

func randomPointInRectangle(rectangle: CGRect) {
    // Attempt 3
//    return CGPoint(x: randomInt(10), y: randomInt(10))
//    return CGPoint(x: 10, y: 10)
    let point = CGPoint(x: 10, y: 10)
    return point
} 

Notice how the error message has changed?

Search 1

'CGPoint' is not convertible to ‘()’

The search results aren’t very conclusive, nothing seems to show up that’s related in the first set of results. Let’s try a different approach.

Search 2
google.com will strip a lot of special characters, let’s alter the search and try it on DuckDuckGo.com

"CGPoint is not convertible to ()” 

The search returns one related result, and it’s the solution to our problem.

https://duckduckgo.com/?q=%22CGPoint+is+not+convertible+to+%28%29%22

Swift Language Programming Guide

Reading or skimming the programming guide on Swift can also help you identify problems. If you’ve never coded before I’d recommend to type in some of the examples as you read, or you can take my online Swift courses.

If you read the , you might have a vague idea of what the error is. Upon seeing the error I remember back to something I read in the book.

Strictly speaking, the sayGoodbye function does still return a value, even though no return value is defined. Functions without a defined return type return a special value of type Void. This is simply an empty tuple, in effect a tuple with zero elements, which can be written as ().

What Xcode is trying to tell you is that it cannot convert a type CGPoint into nothing (an empty tuple). It’s referring to the return type, and if you look at the function signature for randomPointInRectangle you’ll notice that the return type is missing.

Solution

Don’t forget to include your return type in the function definition if you write return at the end of a function.

You can get some pretty strange and indirect error messages. Go back and fix the code to include the return type and the original logic.

func randomInt(number: Int) -> Int {
    return Int(arc4random_uniform(UInt32(number)))
}

func randomInt(number: CGFloat) -> Int {
    return Int(arc4random_uniform(UInt32(number)))
}

func randomPointInRectangle(rectangle: CGRect) -> CGPoint {
    return CGPoint(x: randomInt(rectangle.size.width), y: randomInt(rectangle.size.height))
} 

You have learned how to search for a solution to an error message, how to use DuckDuckGo.com when Google fails, and how to rewrite code to improve error messages in Swift.

Connect

Share the post if you found it helpful, or comment below.

  • Have you encountered a similar error message in Swift?
  • Subscribe to my mailing list and get a free Swift video course.
  • I'm teaching an online Swift iPhone app course.
Posted on November 2, 2014 and filed under Programming .

How I raised over $94,000 on Kickstarter to teach iPhone programming

Funding progress for my 2nd Kickstarter project.

Funding progress for my 2nd Kickstarter project.

In this post I'll cover my background, which led up to launching my Kickstarter projects. I’ll also divulge the process behind—and insight as a result of—running two successful campaigns (see links below!).

You can use my Sketch file to create your project image, so that it fits correctly on the web and in the widgets.

My background

It is my firm belief that you should love what you do. I teach iPhone app programming via online course videos. I have enjoyed programming since I first figured out how to do it. It took many failed attempts in middle school, but I kept trying. Having the ability (i.e. super power) to take an idea and transform it into an app that can control a device or a robot is awesome.

When I first started coding in high school, I enjoyed walking around the classroom helping other students find bugs with missing semicolons in C++ and Visual Studio 6. Helping people was something I came to naturally in the classroom, and I continued the trend in college and online through my personal blog.

I took it a step further when I became a computer science student instructor and later an adjunct professor at RIT. My most recent leap forward has been the one into my role as an online teacher.

Throughout the process, my goal has always been to make cool things and help other people do what I do. I think it’s very important to give back and to have an open mind.

Motives

I didn’t go to college for a piece of paper—I did it to learn. In the process, I found out that I enjoyed teaching people. I delayed graduating for over four years to work on my app company, Artwork Evolution, and finally finished my masters in computer science in May of 2014.

My work experiences at Apple and Microsoft provided a unique look at the inner workings of two of the biggest companies in technology. They also showed me that I didn't want to work for someone else—I wanted to be creative and make things I cared about.

Why teach?

Because I want to clone myself, and I think teaching other people to think like me is probably the lowest-cost cloning option (I’m a little selfish).

There are “best practices” when it comes to writing code, and most aren’t taught in school. My goal is to provide insight on that front and leverage people who are smarter than I am to help teach you the difficult or advanced topics.

How did I successfully raise over $94,000?

Using lots of research, analysis, customer feedback, iteration . . . and personal emails (I sent an email to each backer—find out more below).

For the first project, Nick Schneider and I did a ton of crazy research (he’s a numbers guy—PhD from the University of Pennsylvania—and does scientific research for his engineering degree).

We looked at statistics for successful and unsuccessful projects, and we compared actual projects including apps, games, and online course materials.

I also made decisions based on my gut instinct: What would I like to back? What would make this project interesting?

The option for my first Kickstarter was to launch a new app, like , or to teach online courses for iPhone apps. The decision came down to which would allow us to keep running our company, Artwork Evolution. We found online course projects that raised funds from -, while app project campaigns seemed to either hit lower targets ($2,000-$5,000) or just not get funded at all.

I didn’t have a full-time job, which made the choice easy. If I didn’t get more funding to teach what I know, I’d have to get a job at a company like Apple (which doesn't let you publish apps!)

Tips for the future Kickstarter project creator

There's a lot I want to write about, so this will probably be the first of many posts on the subject of Kickstarter.

Research

Look at successful/unsuccessful projects: what worked/didn’t work?

Ride the popular wave

A lot of my success on Kickstarter is directly related to focusing on a popular technology project. When a project is popular, it gets tons of traffic from Kickstarter users. After it drops down in popularity, the number of backers decreases significantly.

Not everything will be popular, but if you can create a project that has a high share rate and connects, you'll be in a good position to reach success on Kickstarter.

Publish it

Pick a direction and stick to it. Make sure you do 90% perfection, if you spend all your time making the perfect project, perfect prototype, or app, you're never going to finish.

Get something good, be happy with some imperfection and see what you can improve during the project.

Build your persona

Kickstarter backers want to support creative people who have credibility.

  • What makes you unique without saying you are unique?
  • What are your credentials? 
  • Do you blog?
  • Do you host a YouTube channel?
  • Do you have hardware or industrial design experience? {C}{C}

Tell your story

A good story sells on Kickstarter because people want to learn about how you got to where you are and how you’re going to help them.

Capture their emotions and they’ll be more willing to support you by backing your Kickstarter project.

They want to back something that will help or entertain them. Think: does your project sound like something you would back?

Make a good video

A good video is worth a thousand words on Kickstarter. You need to convey the idea of the project within the first 20-30 seconds. Get on camera, explain it, and then show off gameplay or the product that you’re producing.

I started using to create my videos, it was hard, but free to use. I captured camera video and b-roll (secondary shots) with an iPhone 5 for my first Kickstarter video (get a tripod and a iPhone tripod mount called the glif). I did all the editing and bought a music track from .

For my second Kickstarter I was able to use a nicer camera Canon 6D (DSLR) and I used . There's a great course taught by Andrew Gormley on Skillshare for video editing with Final Cut Pro X, it was so helpful! I highly recommend it.

Using Screenflow, I can record my computer screen, and I also have a in to capture video from my iPhone/iPad.

Use b-roll (camera shots of product, people talking, sketches, etc) to make your video more exciting, and less of a headshot. 

I changed the video on every project mid-campaign. Making a good video is a lot of work, and sometimes you just need to hit “publish.” You can re-film a video if your projects not doing well. My first project didn't look like it was going to get funded until I took action to improve it.

My stance has always been to use the best audio and video you can get. Borrow or rent some equipment, especially a good microphone. The iPhone microphone is great if you're close to it, but you'll really want either a shotgun mic, lapel mic, or a $129 usb mic () to get clean audio.

Create a short script

Practice, practice, practice!

I did over 35 takes for my last Kickstarter video, and I edited it twice during the life of the campaign. I changed the b-roll footage and shortened the original video.

Target one to two minutes for your video, and make sure the first 20-30 seconds contains an "elevator pitch" that is going to capture the audience’s attention and explain clearly what you are making.

Good artwork and text copy

Hire a designer to create compelling thumbnails for your Kickstarter project and branding. Don’t spend too much money, but you should be willing to invest in the project.

Writing takes a lot of time. For my first Kickstarter, we spent two months preparing. For the second, we spent two weeks.

Get fresh eyes to review what you write, and don’t be afraid to change it throughout the campaign. I’m constantly making changes and testing them to see what might work better. 

The goal is clarity. For the cost of a coffee, you get some invaluable feedback: test your copy on random people at coffee shops. Do they get your project in the first 30 seconds? If the answer is no, you’ll need to rework it. 

Be open

Things won't go as planned. You might have issues. Be open with your backers, they'll support you as long as you don't lie. Your credibility is on the line when you’re using a Kickstarter. Make sure you can fix or work hard to make up for any issues.

I post regular updates.

Update your project

I could change just about everything about my project. I changed the title, blurb, project text, video, video thumbnail, etc.

Don't be set in stone. Being flexible allows you to craft a compelling story, which should help you get backers. 

It may take a few days for Google/Facebook to index your new changes, so they might still show the old video. Make sure you plan ahead and do updates in the middle of the project, instead of the end.

Post updates as you reach milestones—when you have a stretch goal or addition to the reward tier. My 2nd Kickstarter project has over 20 updates, and most were from the campaign to engage my backers.

NOTE: You can't change the duration, goal amount, URL address, or rewards (see below).

Rewards

Your rewards are set in stone as soon as someone backs them. Make sure they are clear, and easy to read. Worst case scenario, add new rewards with an updated message.

I did that in my second Kickstarter after I added three bonus courses and the Apple Watch course (post Apple announcement). The bundle of 3 courses now became a bundle of 7 courses, and I added a new reward to make it clear.

I like to use capital letter titles in the beginning to help identify the reward so that if I add content to a specific level, it's easier to convey that to backers. It's a lot easier to refer to a named price reward than it is to refer to everything included in the reward when you're talking to potential backers.

Choose your rewards wisely

People don’t back Kickstarter projects to get custom t-shirts with your company logo. Would you?

The rewards need to be compelling, and your first go might not be great.

Every Kickstarter project lasts for 30-60 days. You can add new rewards as you go and find out what backers really care about.

Look at existing projects: which rewards were popular? Which rewards are ignored?

Create rewards that inspire or make someone feel appreciated. 

Throughout my projects, I’ve added bonus content to my Kickstarter. It goes a long way in terms of keeping your backers motivated and providing insight on the project.

Your project is living—you don’t need to add all the rewards in the beginning. Make it interesting and add new rewards partway through the project.

  • Use titles and content to distinguish reward levels.
  • Don't use the waterfall technique (i.e.: don’t give everything to a reward level and below—it makes it hard to add new rewards at different price points)!
  • Don't give everything away for $5.
  • Use bundles to distinguish reward levels.

Skip secondary physical goods

If you're not in the business of making the item, skip it. You'll waste your money and time fulfilling rewards that don't provide value to your project.

Price your rewards intelligently

Add a “9” to the end of your prices. Don't follow suit with every other Kickstarter project that does the $20 or $25 reward levels: make it $29 or $49.

Price the work at something reasonable—something that'll make you feel as though you're not wasting your time fulfilling it. You want to feel good about the project, not stressed out by it.

Rewards must add up to goal

I have seen a lot of Kickstarter projects try to raise $50,000, but then offer the entire project for a $5 reward level. The math doesn’t add up. You’d need 10,000 backers . . . which is really, really hard to get.

I recommend trying to have your project funded with 100-200 backers. Set your rewards to make that possible.

Does paid marketing work?

No. I’m not convinced paid ads works unless you know what you’re doing. If you're boot strapping and doing everything yourself, save ads for a future campaign. It's not worth your time, focus on the project.

Kickstarter doesn’t provide good referral analytics, so it’s hard (impossible) to know if your ads are driving sales or not. You can add the url tag

?ref=somewebsite_message

to the end of a website address to get tracking. However, Kickstarter sometimes strips the code, or it doesn’t show up in analytics.

Also Kickstarter’s web interface only shows a certain number of referrals, while their iPhone app (September 2014) shows a comprehensive list.

My referrals are listed below. You can see some that I had control over and others that were from Kickstarter or news articles about my project.

Lots of sources for referrals that I controlled as well as others that were out of my control.

Lots of sources for referrals that I controlled as well as others that were out of my control.

Note: Facebook referrals are from my friends and followers, not my ads.

What worked?

  • I emailed every backer or potential backer (i.e.: responded to every email/message I received).
  • I posted videos on YouTube with annotations to my Kickstarter project. 
  • I emailed my mailing list about additions to the project (i.e.: Mailchimp referrals).
  • iPhone Life wrote a blog post about my project that drove $2k+ in sales from iPhoneLife.com and flipboard.com.
  • iPhoneDev.tv and PaulSolt.com have links and posts about the project.
  • I posted links on reddit.com.
  • Ranking high on Technology and Apps increased project views and backers.
  • Google search drove a good amount of backers.

What didn’t work?

I spent $789 on Facebook ads, some for my Kickstarter campaign and some for my course website.  It was mostly an experiment to learn how to create better ads. I was A/B testing different ad copy and images spending $30/day for a short period of time. 

A/B testing is where you have two ads that are identical, except you change the picture, or one of the lines of sales copy. Your goal is to compare the change (i.e.: scientific method) and test your sales copy hypothesis. The goal is to find ads that convert to sales, and in this case Kickstarter backers.

I don’t recommend ads unless you can track conversions. To do advertising you need to be willing to spend money to A/B test ads against each other. If you can’t track conversions, however, then you’re shooting in the dark.

I was able to drive one $149 backer from BuySellAds.com for a $30 ad, but subsequent ads ($60) did not convert (or I didn’t see referral).

More targeted ads may have worked better, but I didn’t focus on this since my personal communication techniques (i.e.: email) were much more effective.

Conversion Rate

The conversion rate is based on the number of video plays and subsequent backers.

  • 1st Kickstarter: 705 backers / 9,627 plays (41.04% completed) = 0.0732 (7.32%)
  • 2nd Kickstarter: 492 backers / 8,718 plays (68.33% completed) = 0.0564 (5.64%)

A better conversion rate would help, so I probably should experiment with a different video, or my story isn’t adding up: if people are interested enough in the topic to watch your video, but then don’t contribute to the project, there must be some sort of disconnect.

Email or message every backer

I use TextExpander to create quick messages to backers. It helps quickly paste in links to different resources that backers ask about.

1. Typing ";kick2" gives me the Kickstarter project link: 

2. Typing “;ty” creates the following message and prompts me for the backers name. Pressing enter creates the message and I can quickly send it to each backer who supports the project.

Thank you John,
I'm curious, how did you find my project?
How can I help you learn to make iPhone apps?
-Paul
PS Please share this project with your friends on Facebook or email. I appreciate your support!
Project Link: https://www.kickstarter.com/projects/paulsolt/31-days-make-iphone-apps-and-games-with-swift-for/?ref=kmessage

3. I’ve sent over 490 emails to backers and responded to hundreds more—sometimes multiple times.

On my iPhone email account (), I sent an additional 295 email replies during the Kickstarter campaign. Lots of typing!

  • I really think it’s important to get insight from your backers.
  • Find out where they came from, what their background experiences are, etc.  
I send hundreds of emails, sometimes in big spurts.

I send hundreds of emails, sometimes in big spurts.

Build an audience

Start building your audience today. Just remember that most of your friends and family will not support your Kickstarter project. Don't feel bad—they aren't your target audience.

If you want to have a successful Kickstarter campaign, you need to build an online audience that you can market to. I have a following from my courses on udemy.com, skillshare.com, iPhoneDev.tv/blog, Facebook, and Twitter.

My Mailchimp mailing list has over 860 people, which is something I’ve spent the past year and a half growing. Most of the growth has been from my personal iPhone blog, where I include a signup widget alongside my blog posts.

Giving something away for free is a great way to get someone’s email address. They’re happy to provide contact information if you have something they value.

A snapshot of my subscribe box on my website. I change what it says regularly.

A snapshot of my subscribe box on my website. I change what it says regularly.

Teaching online courses is a great way to establish a web presence.

Icon Design

The Kickstarter video icon is 1024x768, however it gets cropped for the smaller views. Use my Sketch template to design your icon

Use this template to make sure your text is readable.

Use this template to make sure your text is readable.

Stretch goals

These goals are open-ended goals that many Kickstarter project owners add to encourage backers to share the project to unlock new rewards.

Don’t post these immediately. , especially if they deviate too much from your project.

I think stretch goals are a good way to motivate people to share your project, but they really only come into play after your project is funded.

Having a plan before you start is good. Think about what additional things you can offer without adding too much work to your side. You want to be able to manage your stretch goals. I’m still working to fulfill stretch goals from my first Kickstarter. 

It’s better to over-deliver than over-promise, which I wish I had done first. Apple announced a new programming language, which altered my direction with my stretch goals from the first Kickstarter.

You want to make sure your stretch goals don’t overwhelm you. Wait to post them until after your project’s funding goal is reached. Your feedback from backers should help steer the direction. I used Google forms to survey my backers about potential extras.

Failure is an option

You can re-run a failed project . . . and, in fact, it could be better for you. You’ll learn what does and doesn’t work and can better plan the second time around.

Put yourself out there and see what people have to say. Worst case scenario, you fail and try again. My almost wasn’t going to get funded until I took action to improve my video and the clarity of the project description.

1st Kickstarter project - It almost failed until I changed the video, rewards, and text.

1st Kickstarter project - It almost failed until I changed the video, rewards, and text.

Last days

The Kickstarter project locks after the campaign ends. Make sure at the top of the project you include information about you, and where "late backers" can go to fund the project (if that's an option).

My first Kickstarter raised an additional $6,000 from late backer payments, so I really raised closer to—if not more than—$100,000.

Consider these late backer payment options:

  • Squarespace.com – Business website; e-commerce option for digital or physical goods
  • Gumroad.com – Sell anything digital or physical
  • Stripe.com – Build something native using easy payments

Connect

Let me know if you want to learn about anything else related to running Kickstarter projects.

  • Email me at
  • Follow me on Twitter:
  • Subscribe to my mailing list and learn to make your first iPhone app with Swift.


Posted on September 29, 2014 and filed under News, Tips .

iPhone app, iPhone game, and Swift Programming Courses for iOS 8

Swift iPhone Apps are the Future

Do you want to learn how to make iPhone apps?

Have you heard about Apple's new ?

Do you want to make iPhone apps or iPhone games for iOS 8 and the next iPhone 6?

iPhone Course Bundle

I'm launching on October 6th, 2014.

Swift is a modern, fast, and safe programming language. It will help you create apps faster and write code that doesn't crash. It's replacing Objective-C and you need to learn it now.

Sign up to get access to the new iPhone app programming courses that . You will learn how to make games with Sprite Kit, and how to .

on the retail price of $99/course. 

Stay Informed

Signup for the Swift mailing list for additional app programming resources.


Posted on August 18, 2014 and filed under News .