Archive for » February, 2010 «

Also reading other iPhone books from library

Besides the Core Data book, I have also borrowed two other iPhone books for my bedtime reading.

Programming the iPhone User Experience expands on the required Apple HIG.  Good read, especially on parts of iPhone UI that you seldom use.

The iPhone Developer’s Cookbook has lots of sample code that I may use later.  Wish I had this book earlier.  Although a bit outdated, but still great as a reference.

OK and no point buying these books as you can get them from the library when you need them.

TableView and TableViewCell again

Although the tableview and tableViewCell are probably one of the first you will learn when starting the iPhone SDK.  Most of the time, you will just mangle it using some of the more popular and easy way to populate the cell.

For me, I found using this way works out best for me.

Create all the necessary labels in init. For each labels, create a function to return CGRect that describe the actual position and layout.

CGSize ratingSize = [rating.text sizeWithFont:[UIFont boldSystemFontOfSize:24.0]];

self.contentView.bounds.size.width

Use the bounds sizes and get the label  CGSize to determine  required space for the label.

In your layoutSubViews, [sizeLabel setFrame:[self sizeLabelFrame]];

Now, you can put labels exactly where you want it in your TableCell.  This should work for other views too.

PS.  This will be important when you port your iPhone app to iPad should you need  shouldAutoRotate.

Category: iPhone  Leave a Comment

Borrowed the Core Data book from library

Guess what?  The author Marcus is actually the famous blogger at Cocoa is My Girlfriend.  Got lots of good tips from him, especially the iPhone chapter.  Give me better insight to the Core Data API.

Highly recommended reading

Types of Gas and Electricity Tariffs

This energy tariffs buyers’ guide outlines the different types of energy tariff available.
You buy gas and electricity in kilowatt hours (kWh) – this is what you’ll see on your bill.

Gas tariffs

Gas tariffs are often at two rates. You might pay 4p for the first 5,000 kWh each quarter, say, and then a lower figure, 2.5p for instance, for each subsequent kWh.
Because suppliers charge different rates, you can lower your gas bills by switching to the tariff that’s best for your own use.

Electricity tariffs

Electricity tariffs work in a similar way, although the pricing is different. You might pay 24p for the first 125 kWh each quarter, say, and then 10p for each subsequent kWh.
Because suppliers charge different rates, you can lower your electricity bills by switching to the best tariff for you.

Dual fuel tariffs

Dual fuel tariffs work the same way as gas and electricity tariffs. However, suppliers give discounts for taking both products from them.

For many people, the discounts mean that a dual-fuel tariff – switching both gas and electricity to the same supplier – works out cheapest.

Green tariffs

With green tariffs, you still get the same gas and electricity. The tariffs work in several ways – but many match energy you use against supplies from renewable sources.
Once you’ve compared gas and electricity prices with us, you can choose to compare just green tariffs.

Online tariffs

Some of the cheapest tariffs are online only. You don’t get a paper bill, but you manage your account over the internet instead – making payments, giving meter readings and so on.

The advantage of giving meter readings online is that you know you won’t over or underpay, compared with a company estimate. Plus you don’t have to wait around for the meter reader.
Once you’ve compared gas and electricity prices with us, you can choose to see just online tariffs.

Tariffs with rewards

As well as cheaper gas and electricity prices, you can also benefit from rewards with some companies – there’s often a reward for signing up and more rewards depending on your bill.
Once you’ve compared gas and electricity prices, you can choose to see just tariffs with rewards.

Fixed and capped tariffs

With fixed-rate tariffs, the price is guaranteed not to change for a certain period. With capped tariffs, it won’t go above a certain level.
These accounts help you budget – you know the exact or maximum amount you will pay.
The downside is that these tariffs are a little more expensive than standard ones, and you won’t benefit fully (at all with fixed-price tariffs) from future falls in energy prices (if there are any).
These tariffs are often for a set period – you’ll pay a fee if you want to switch within the set time.

Economy 7

With an Economy 7 meter, you pay less for electricity you use off-peak (between midnight and 7am), but more during the day. They’re commonly used with storage heaters.
If you have one, use timers to run washing machines, dishwashers and so on at night.

Prepayment meters

Prepayment tariffs are the most expensive way to pay for gas or electricity.
You pay in advance for what you’re going to use, by charging up your key or card at prepayment outlets.
To change to a cheaper way of paying, such as direct debit, you’ll need to have the meter physically changed. You may have a credit check run on you as well.

Repeating data when importing

Looks like I got some problem with the managed object retain cycle.  Was working fine in previous cell feed version.  Got a series of repeating values during import of data.  Need to have a closer look at the Core Data docs for more info.  Did follow the standard efficient importing earlier.

[object release];
[managedObjectContext save:&error];
[managedObjectContext refreshObject:object mergeChanges:NO];

Cell Feed vs List Feed when importing Google Docs

List Feed halved the time needed and create less objects while importing.  When using cell feed, the iphone completely bombs when reading.  When using list feed, it did import all the data but required 20 minutes.  Now it is time to import in batches to follow the feed.

Category: Google Docs  One Comment

Reducing memory footprint when using Core Data

Got this persistence memory overload when importing data from a Google Docs spreadsheet into Core Data.

XXXXX <89476b67fcbc4c49f1ba498af5d06040>   17483 (jettisoned) (active)

Give up after 17483 count.  At the moment is using [managedObjectContext save:&error] at the end of the input.  Maybe can consider saving every record at the end of each loop.

Predicates looking for Name

Sorted out the search text criteria for search list.  But the search expression is currently too crude.  Need a better way to identify words within name.

Using the basic like[c] expression which is grossly inadequate.  Maybe regular expression or a combination of predicate complex expressions to cater for this.

Found a nice solution for this iTunes like search from Cocoa Is My Girlfriend.

Overkill with above solution; just use @”x contains[c] %@” will do.

Using Predicates for Search and Core Data

Most search are based on existing table data that is fetched.  This involves creating another list filtered on the existing list.  This is alright for small list.  For bigger list in terms of thousands of items, you need to justify that memory space in maintaining two sets of list.  Memory is always a premium in iPhone.

The usual fetch request when using is great for the initial list.  For searchable  list based on the UISearchBar, you are likely to type in the criteria string for the list.  This is where predicates will be most useful.  You can setup a predicate based on your search text and pass it as a parameter in your predicates before fetching the search list.

This has the advantage of having a single round trip in fetching the new list.  Also, you do not need to create two lists for the usual search.  That being said, now I need to put this into action.

Clash of the iPhone & iPad SDKs

It seems like in the haste of installing 3.2 beta, together with the latest 3.1.3 can crash your Xcode build settings.

It is highly recommended that you install beta SDKs in separate folders as compared to the standard /Developer for the released SDKs.  Found this out the hard way, and now all my build codes are default to /Users as compared to the usual /3.1.3 The mixed up is too painful to comprehend. “Ouch” X!

Found some information regarding this at the Apple support. I will try to remove all traces of the beta.  Do comment if you have discover any work around.

Additional info from tuaw  here