Reloading a UITableView data when navigating back into a UITabBar

So i recently ran into an issue where i could not get a UITableView to reloadData – It was a view connected to the TabBar – When someone clicked Search a table was brought up, they would click a row on the table and edit the values – then click back and it should have reloaded the data – I had [tableView reloadData] in the viewWillAppear method for the View.

The trick to getting it to work is add the following code to the viewWillAppear method for the TabBar Controlling View

-(void) viewWillAppear:(BOOL)animated
[super viewWillAppear:animated];
[self.selectedViewController viewWillAppear:NO];

This calls the viewWillAppear method for whichever view is selected.

Worked a treat for me.

Xcode, Cocoa and Objective C. Ah the joys of it all!

Asynchronous Image Loading in Table Cells with Cache

So i’ve recently created an app that used image in the UITableView cells. When i would load the view it would take forever once the button was pressed for the view to be pushed onto the stack.

I realised it was due to the images needing to load from my server. So i implemented a number of Asynchronous Image Loading classes but they all weren’t sufficient for what i wanted.

I needed something that cached the images, something that was super easy to implement, and robust.

Enter SDWebImage

With a simple call to your UIImageView you can make image loading hassle free and much faster than traditional image loading.

[cell.imageView setImageWithURL: [NSURL URLWithString:@""]
placeholderImage: [UIImage imageNamed: @"placeholder.png"]];

You’re done!

The class also has examples in the Readme about adding Asynchronous image calls into other elements etc.


Refreshing Map View (MKMapView) for iPhone development

Ok so i just spent a long time searching how to reload a map view.

It’s quite simple

[map setRegion:map.region animated:TRUE];

The problem i was having was when i was adding annotations i was adding them through a background thread. So if you want to reload a map after adding annotations make sure you are calling it back in the main thread.

//add to your threaded code
[self performSelectorOnMainThread:@selector(reloadMap) withObject:nil waitUntilDone:FALSE];

//create function
-(void) reloadMap
[map setRegion:map.region animated:TRUE];

Hope this helps someone, if it does let me know so i can at least feel like 2.5 hours wasn’t a complete waste :P

Content Is Not Allowed In Prolog – Google API

Recently I’ve been having to work with the Google Provisioning and Email Settings API, which¬† I thought would be no big deal.¬† But soon, like a child who’s ice cream has just fallen on the ground, I was in tears and frustrated.

The issue wasn’t necessarily the API, or the PHP code that I was using to generate the calls to the API, but it was the error message that I kept getting back when I tried to send my PUT requests.

Content Is Not Allowed In Prolog.

Generally, this error indicates that there is content before the XML declaration, for example a space, or pehaps a gremlin. But in my case, there was nothing in before the <?xml version="1.0" encoding="utf-8"?>, and I checked and checked, then checked some more. And after that I checked some more, before checking even more.

So, after weeks of trying everything from different XML classes, writing the XML to a file, and creating a wig from the hair I’d ripped out of my head to cover my new found baldness, I finally figure it out!

With the Google API, like most API’s, it requires authentication. For the purposes of the app I’m working on we are ClientLogin authentication method which requires you to send an authentication token as part of your request headers.

$headers = array('Content-Type: application/atom+xml; charset=utf-8',
'Content-Length: '. strlen($xml),
'Authorization: GoogleLogin '. $authToken,
'Connection: close');

Those were the headers I was sending to those who do no evil (of course that depends on what you’re definition of evil is).
After dumping the headers to the browser I noticed something unusual…. after the last character of the auth token.. there was a SPACE.
So I changed

'Authorization: GoogleLogin '. $authToken,


'Authorization: GoogleLogin '. trim($authToken),

and voila, no more Content is not allowed in prolog error.

Hopefully, this will help some other poor sod out there who has been pulling their hair out. On the plus side, I now have a very cool wig.

Oh, and because I had so much trouble finding information on sending a put request to Google, here is some sample code:
Note: This code assumes you already have the auth token from Google.

$headers = array('Content-Type: application/atom+xml; charset=utf-8',
'Content-Length: '. strlen($xml),
'Authorization: GoogleLogin '. trim($authToken)),
'Connection: close');
// Initiate Curl
$ch = curl_init();
// Tell curl what URL we are putting the information too
curl_setopt($ch, CURLOPT_URL, $PUTUrl);
// Open the file we are going to put to the URL
$fp = fopen('test.xml','r');
// Tell curl we are using the PUT request
curl_setopt($ch, CURLOPT_PUT, true);
// Give curl the handle of the file we just opened
curl_setopt($ch, CURLOPT_INFILE, $fp);
/* We need to know the size of the file 
   (I had previously created the xml earlier in the 
   script and saved it to a file, hence the reason 
   I'm using a variable called $xml */
curl_setopt($ch, CURLOPT_INFILESIZE, strlen($xml));
// Set the user agent
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0)');
// Set the timeout.  If the request has not completed in 30 seconds, terminate the call and show results
curl_setopt($ch, CURLOPT_TIMEOUT,30);
// Add our headers
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// Close the file
// Do the curl request
$output = curl_exec($ch);
    echo 'An error occurred with the request'. curl_error($ch);
    echo $output;

Mac Messenger Signs me out everytime I open hotmail

Hi All

I think i’ve solved this issue i’ve been having since i upgraded to Messenger for Mac 8.

Everytime I opened Hotmail it was logging me out of my MSN. I figured it had something to do with logging into web messenger. As i had done this once before.

What you should do is open hotmail -> Sign Out of Web Messenger (Normally located on the left underneath your folders). Once you have logged out you need to delete all your cookies. The way i did it was using the Web Developer Toolbar plugin for Firefox – but you can do the same thing with Tools -> Clear Recent History -> Make sure All time is selected and Cookies is selected then delete.

It worked for me. Hopefully it works for you as well.

Let me know if it didn’t.


Messenger won’t sign in on mac

If you can’t seem to sign in to MSN messenger or windows live messenger on the Mac and it keeps saying there is an error or possible network connection.

Click Sign in with a different account or change your online status -> Click the Clear Account History Button -> Restart the program -> Sign In

Worked for me – i think it’s an issue with at one stage logging in through hotmail messenger.

Hope this helps

WP Ecommerce Scale Image instead of Cropping

Ok i recently had the problem where i wanted to define a max size for the images in my shopping cart. I didn’t want to set a static size for my entire carts images.

Eg I wanted it to be max of 300px height or width but not 300px wide and 300px high.

So if the image is landscape it would be 300px wide and whatever it works it out to be height (eg 200px, anything lower than 300px). If it was portrait then i want the largest dimension to be the height (at 300px with the above example).

Here are the things i did to achieve this.

Please note – you will need knowledge of PHP to achieve this.

First you need to add this section of code to the file misc.functions.php – located in WP Ecommerce folder/wpsc-includes/
Add this code to the switch($scaling_method) { statement (make sure it’s above the last option
case 'scale':
if (empty($width) || empty($height))
if (!empty($width))
$maxSize = $width;
else if (!empty($height))
$maxSize = $height;
if ($width > $height)
$maxSize = $width;
$maxSize = $height;

list($temp_w, $temp_h) = calculate_image_width_and_height($source_w, $source_h, $maxSize, $allowEnlarge=true);
$width = $temp_w;
$height = $temp_h;



// select our scaling method
$scaling_method = 'cropping';


// select our scaling method
$scaling_method = 'scale';

You’ll also have to change theme.functions.php in the same directory as misc.functions.php
You’ll need to remove the css that the file creates.
Namely the Single View Styling
And the last 3 Default View Styling css statements.

The final change is part of your theme – i’m using the default theme, i’m not sure if you’ll have to change it for other themes or not.

Default theme – change single_product.php put a table around the following divs (below the div class=’textcol’ div)
<table width='100%' class='nocolour'>
<td valign='top'>
Image Stuff is here
<td valign='top'>

I think some css changes need to be done to get this to work (namely removing the postition:relative and some of the floats and positioning for imagecol and producttext)

Once that is all done – you need to go the Presentation area of the Settings Area of WP E-commerce. Go to the Single Product Image Size part and fill in only one of the text boxes, leave the other blank.
That should make it work for your images. I’ll be doing this for another client soon so if the process is different i’ll let you know

Creating a catch all sub domain system

Ok recently i needed a catch all system for a website i was creating. All the tutorials i went through needed me to change the httpd.conf file. Pretty hard to do when on shared hosting. But found the solution to it using CPanel functions.

Instead of adding * to the httpd.conf file

ServerAlias *

Answer below

You can create a subdomain using the cpanel function with * as the subdomain title. You can set it’s fileroot as public_html to redirect to the root folder, or set up as something else.

if you want an example of htaccess that would send the subdomain to the script –

<IfModule mod_rewrite.c>
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^(www.)?([a-z0-9-]+) [NC]
RewriteRule (.*) $1?subDomain=%2 [L]


could not complete the request because the layer is not a valid text layer – Photoshop error

Hi All

I recently had this error message come up whilst trying to open a file that i had created. I was opening it on the same computer. Restarting Photoshop was able to solve the problem. Hopefully this helps. I’ve read in other forums that you can normally open it in another photoshop program on a different computer and resave it. But didn’t need to do that for mine

SWFUpload gets stuck at uploading…

Recently I came across a problem while installing SWFUpload on my latest site. I had the problem before but couldn’t remember what the solution was.

When I uploaded a file with SWFUpload on my mac (OSX 10.5) it would get stuck at the uploading… status

This was cause by my upload_url file not returning any text at all. Make sure when you set up the system that for every error case that some sort of output is displayed. And also on success.

In PHP I simply output the error message then die;