Archive for 'Programming'

Supporting iCade

So you heard about that iCade thing for the seriously retro iPad vibe?

icade_angle_lg-580x363.jpg

If you’d like a full review, check out

Thoughts on the iCade (and on using it with Flash games)

but we’d just like to note for your development pleasure this bit, if you’ve already decided that would be a neat thing to support in your games:

So how do you add iCade support on iOS? Luckily someone made a library that makes it super easy: https://github.com/scarnie/iCade-iOS/ – basically you just add a special view to your main view controller which listens to keyboard events, and that view then sends messages to a delegate when buttons are pushed. There’s really not much more to it…

“Super easy” is a good level of integration complexity, yep.

UPDATES:

Adding iCade Support to Your Game

Continue Reading →
1

Tip: Keyboard Area

As you know if you’ve ever tried it, it’s harder than you’d think it ought to be to figure out just where the keyboard is coming up on the screen. Here’s a tip which looks like a good approach:

Calculating Area Covered by Keyboard

I’ve seen several approaches to this so far, but they often hard code a certain position of the view or sizes. Like assuming that the covered view always reaches towards the bottom of the screen or always has a certain amount of space taken away from it by the status bar, navigation bar and possibly toolbar.

The whole thing gets even more complicated by the fact the the coordinate system of the app’s window is always in portrait even though your app rotates. So is the frame of the keyboard which you can get from an info dictionary in several notifications. I’ll show you the most universally working method I was able to come up with…

Those bars at the bottom are usually the tricky bit, we find. If this actually does handle them properly in just that little bit of code, we’ll be pretty impressed!

Continue Reading →
0

Bezier Path Boolean Ops

This is a solid series on manipulating NSBezierPaths:

How to implement boolean operations on bezier paths, Part 1

This post will focus on finding intersections between individual bezier curves, and the next will show how to implement the boolean operations based on that. The algorithm presented will be able to handle arbitrary closed bezier paths, including those with holes and self intersections.

If you’re impatient, you can skip straight to the commented source code

How to implement boolean operations on bezier paths, Part 2

This time I’ll show how to conceptually perform the four common boolean operations: union, intersect, difference, and exclusive or…

How to implement boolean operations on bezier paths, Part 3

In this final installment I’ll present the algorithm used to implement the boolean operations…

Beats figuring it all out yourself!

Continue Reading →
1

Core Text Tutorial

This is a rather nice introductory piece to the somewhat underdocumented Core Text framework to go along with the various bits and pieces we’ve noted before:

How To Create a Simple Magazine App with Core Text

This tutorial will get you started with Core Text by taking you through the process of creating a very simple Magazine application using Core Text – for Zombies!

You’ll learn how to:

  • lay formatted text down on the screen;
  • fine tune the text’s appearance;
  • add images inside the text content;
  • and finally create a magazine app, which loads text markup to easily control the formatting of the rendered text.
  • eat brains! Ok just kidding, that’s only for the readers of this magazine.

Good stuff, good stuff.

Continue Reading →
0

Tip: CoreGraphics Patterns

Here’s a snippet demonstrating, as the title says,

Using Patterns in Quartz2D

There’s not a ton of information out there about how to use patterns with the Quartz framework and drawing patterns, especially about combining it with UIColors ability to create colors with patterns…

Also sample project on github. And what actually got our attention enough to merit a blog note, check out

Stripe Generator 2.0 — “The Ultimate Tool For Web 2.0 Designers”

which looks like a rather nice site indeed for generating stripey background patterns.

Also might want to check out the latest from the ever expanding Wenderlich tutorial empire,

Photoshop Tutorial: How To Get The Repeating Image From A Pre-Made Pattern

h/t: @pzearfoss!

Continue Reading →
1

Threadsafe Date Formatting

[OBSOLETE INFORMATION! SEE UPDATES!]

So let’s say you’ve got a project that involves a bunch of repetitive date manipulations, like merging multiple RSS feeds into a single timeline. And having done some timing, and read QA1480, you’re quite aware that

[NSDateFormatter alloc] is insanely expensive. If you’re doing it more than once, YOU’RE DOING IT WRONG.

So you’re doing it only once. And then you find that you start getting a disturbing number of crash reports with terminal lines like

Thread 9 Crashed:
3 libicucore.A.dylib 0x300cafa4 icu::DateFormat::parse(icu::UnicodeString const&, icu::ParsePosition&) const + 120

And that makes you remember, uh-oh … NSDateFormatter is thread-unsafe. Whoops. Well, that throws the above statement for a loop.

However, we can edit that to the actually correct

If you’re doing it more than once per thread, YOU’RE DOING IT WRONG.

by using thread local storage as suggested in this Dropbox forum posting, for something like

https://gist.github.com/alexcurylo/1b1147bc94e8bc59d84f

That should work out nicely for you.

UPDATES:

Note our earlier DateCalculations, Tip: NSDateFormatter Localization, Snippet: Ordinal Days, Snippet: NaturalDates, Code: NSDate (Helper), NSDateFormatter formatting

DateFormatter Reference:

On iOS 7 and later NSDateFormatter is thread safe.

On OS X v10.9 and later NSDateFormatter is thread safe so long as you are using the modern behavior in a 64-bit app.

On earlier versions of the operating system, or when using the legacy formatter behavior or running in 32-bit on OS X, NSDateFormatter is not thread safe and you therefore must not mutate a date formatter simultaneously from multiple threads.

If you’re parsing ISO-8601(JSON) dates, try Date Parsing Performance: NSDateFormatter vs. SQLite instead.

The Hit List Diary #21 – Lenient Date Parsing

FormatterKit has time intervals, and oodles of other goodies.

SwiftMoment: Open Source Swift Library For Working With Dates Inspired By Moment.js

Global Nerdy’s “How to work with dates and times in Swift” articles (so far):

Tempo: “Date and time manager for iOS/OSX written in Swift.”

if you are using NSDateFormatter -setDateFormat: without NSDateFormatter +dateFormatFromTemplate:options:locale:, you’re probably doing it wrong.

CVCalendarKit: “A wrapper around NSDate which provides a convenience way for dealing with dates.”

SwiftDate: “Easy NSDate Management in Swift.”

Timepiece: Open Source Swift Library Providing A Great Syntax For Working With Dates

Predictable Date Formatting “Apple specifically recommends using the “en_US_POSIX” locale [to parse an Internet-style date]”

Continue Reading →
5

Fixing Symbolication

So you been having trouble with symbolication since the Xcode 4 release? And of course you checked out our Xcode 4 resources post and so applied the version on github which was described here, but that didn’t fix all your problems? Well, here’s a new take on it with a rather simple solution:

Fixing Xcode 4′s symbolicate utility to get comprehensible crash logs

…Digging into the errant symbolicatecrash source, I noticed that the code that finds the executable path tests each candidate using otool, but doesn’t seem to be able to comprehend the output from otool caused by running it on the wrong architecture.

So, replacing the rather unhelpful ‘die’ statement on line 323:

die “Can’t understand the output from otool ($TEST_uuid -> ‘$otool -arch $arch -l $path’)”;

With a “No, it ain’t this executable” response:

return 0;

…solves the problem immediately. Now I can drag crash logs straight into the Organizer in Xcode, and it’ll symbolicate correctly.

Give that a shot if you’ve been having problems and see how it works for you!

Continue Reading →
0

Saved Files Alert!

So does your iOS app write any of its working files to NSDocumentDirectory? Yep, pretty much all ours do too. And it looks like that might be a disaster waiting to happen if the situation described here comes to pass:

Game, utility or whatever app you are developing. Know this… as of iOS 5; the USER will have full visibility into your apps Document folder. <- as of beta 2

… Oh and in the new multi-tasking order of things… you guessed it… you can of course DELETE these files WHILE your app is in the background, which again; only YOU know what problems that will cause…

Gleep! Looks like it’s time to start being a lot more careful about file management. If you already were using NSLibraryDirectory where appropriate and writing all your code assuming users could mess with NSDocumentDirectory at will, well our hat (had we a hat) is off to you sir/madam. For the rest of us lazy types for which a rushed update appears in order, the timely warning linked above also includes a code snippet that looks like a good template for a one-time move of your data files and whatever from NSDocumentDirectory to NSLibraryDirectory. Handy, that.

h/t: @gregmeach!

Continue Reading →
4

NinevehGL

Here’s another option for you if you’re looking for something in the 3D engine space beside the cross platform options we collected most lately a couple days ago, or the cocos3d extensions to cocos2d, or that Galaxy Engine thing we mentioned a while back; this one’s called NinevehGL and why yes, they look like they are aiming their target market directly at trolls:

The NinevehGL’s golden rule is:”Keep it simple!”

So we think if we can’t teach you a feature in 3 min, that feature is not good enough. Each video tutorial bellow is made of 3 min, there are 10 basic lessons to teach you. If you watch the videos and/or read the tutorials you will learn to construct almost anything with NinevehGL. Besides, there are some other advanced topics you can learn in the full documentation guide…

Yes, yes that sounds like a compelling reason to pay attention to them, indeed. Free, open source, Objective-C, and they’ve just entered open beta. Try it out and let us know what you think!

h/t: ManiacDev!

UPDATES:

Adding an OpenGL ES view to your project using NinevehGL

Continue Reading →
1

AppA Source

Here’s a new service from the AppA folk who you may remember us being mildly baffled by a while back — AppA Source!

Source is an online directory of code, software, meetups, conferences and other items of interest to iOS developers.

It is intended to be a ‘one stop shop’ for developers to find the tools and information they need to create amazing apps for the iPhone, iPad and iPod touch.

Source is still undergoing rapid development, and is currently considered beta. However, we are keeping it online as it is already a useful source of information…

Looks like they’ve made a decent start, and hey you can never have two many sources of development news; so go ahead and follow @appasource if you want to keep tabs on how they progress!

Continue Reading →
0
Page 30 of 99 «...10202829303132...»