Categories
Computing General ios iphone

SQLite ORDER BY does not work on integers: time for an index

My current project uses SQLite as it is really the only game in town on iOS. SQLite indexes provide an incredible performance boosts when you are dealing with large datasets. They apparently play a crucial role when it comes to something of a foregone conclusion in other databases – sorting.

What stumped my colleagues and I was that we had a database table where one of the columns had an INT (and also tested using an INTEGER) type (and yes – they are all NUMERIC to SQLite) – and ORDER BY kept returning incorrectly sorted results. According to this post on Stack Overflow, when you have a SQLite query that uses the ORDER BY, it may rely on temporary tables. Those in turn 'confuse' the database when it runs the query to sort your table.

The answer – add an index. Something as simple as

CREATE INDEX index_name ON table_name
(
   NAME_OF_COLUMN_TO_SORT ASC
);

Once you add it – you are, well – sorted out.

Share
Categories
Computing ios iphone

Positioning UIPopoverController

The iPad has a great UI control – the UIPopoverController – most notably used in its email app when it is in portrait mode. To show, or 'present' a UIPopoverController you have two methods:

– presentPopoverFromBarButtonItem:permittedArrowDirections:animated: 
which is used to present the popover from a UIBarButton in, say, a navigation bar.

– presentPopoverFromRect:inView:permittedArrowDirections:animated:
which is used to present the popover from a location specified by a CGRect as its first parameter.

Unlike other UI controls, this CGRect actually specifies the location of the UIControl you want the popover to point at, or at least be next to. For example, the button that triggers the showing of the UIPopoverController. That is, the UIPopoverController does not use that CGRect for its own positioning – but as an 'advice' where it should be hovering.

You can also tell it where you want it to hover using the permittedArrowDirections flags, which will try to place it say, above (if the arrow direction flag is down), to the left (if the arrow direction is right), etc.

Share
Categories
Computing iphone Mac OS X

Why I am uninstalling Xcode 4 gm seed Beta

The person who helps tutor me into iOS happiness recommended that I try Xcode 4's beta. He felt is was ripe and ready to go. I followed his advice, installing Xcode in a separate directory than Xcode 3 (.2.5). Today I am uninstalling Xcode 4's beta. Here's are some of my impressions from my experience:

  1. Git integration: great step forward here. Xcode embraces the Git version control system and detects existing command-line setups. Only thing is that Xcode only allows you to commit to your local repository. There is no push capability.
  2. Adding files – source code or images – is a huge issue. Drag and drop does not work properly and mostly ends up with an error message. More crippling is the fact that if you use the navigation menu to import files into your project, it imports them into a purgatory area that appears above the root project icon in the file listings view. What causes the real issue is the fact that if you then try to move those files back into the project by dragging them, they will be copied into the project. There is no way to delete them from the purgatory state inside Xcode. If you try to compile the project, the compiler will complain about duplicate files (even images) with the same name. If you delete the file from the command line or finder, you are stuck with 'ghostly' listings. The project will compile but the clutter grows.
  3. Xcode 4 sets up a new project structure, different than Xcode 3. It has fewer folders and overall seems a bit more cluttered to my newb eyes. Adding groups is also unintuitive as the only way to name a new group is by creating it first, and then single-clicking its name.
  4. Project properties are a huge step forward. Configuring Xcode to use libraries and set up apps on the iPhone and iPad is now outside of the source plists and in a pleasant user experience.
  5. Xcode 4 integrates Interface Builder into the IDE's window; no longer a separate app. It uninstalled Xcode 3's version of Interface Builder and if you try to open xib files in Xcode 3 it opens Xcode 4's version. That would still be cool had it not for the fact that the new Xcode 4 Interface Builder has issues in detecting properties in the files you create in Xcode 4.  

In summary – Xcode 4 works, mostly. It does crash – but gracefully. Yet I would recommend against installing it for serious development and even more, against installing it side by side with Xcode 3. 

Share
Share