iOS webView open a JavaScript link in Safari

After working on updates for our Virtual Swanage iOS app that uses a JavaScript based webview for information, I ran into a problem where by a JavaScript window.location event would only open up a page within an existing view and it was not possible to make a URL jump out of an application and into Safari without resorting to <a> links. I came up with the following solution to get around this problem.

The code below should be placed in your iOS application within the same class as your webview. When a link on a web page is selected the shouldStartLoadWithRequest method is called. The URL request is checked and if the URL contains safari:// or safaris:// instead of http:// or https:// the method overrides the default loading action and passes the URL to safari instead.

By using this method you only need to update any URLs on your website that you want to open in Safari with safari:// instead of http:// or safaris:// instead of https://.

- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {
//CAPTURE USER LINK-CLICK.
   NSURL *url = [request URL];
   NSString *currentURL = [url absoluteString];
   NSRange textRange = [currentURL rangeOfString:@"safari://"];
   NSRange textRangeSecure = [currentURL rangeOfString:@"safaris://"];
   if((textRange.location != NSNotFound) || (textRangeSecure.location != NSNotFound))
   {       
      NSString *newURL;
      if(textRange.location != NSNotFound){
         newURL= [currentURL stringByReplacingOccurrencesOfString:@"safari://" withString:@"http://"];
      }
      if(textRangeSecure.location != NSNotFound){
         newURL= [currentURL stringByReplacingOccurrencesOfString:@"safaris://" withString:@"https://"];
      }
      url = [NSURL URLWithString:newURL];
      [[UIApplication sharedApplication] openURL:url];
      return NO;
    }
    else{
      return YES;  
   }
}

HTC HD7 and Apple iPod Touch Wooden Stand

Following from the previous HTC Desire Custom Wood Dock project, I have purchased a HTC HD7 phone and also an Apple iPod Touch.

The plastic ipod stand wasn't very well made and I haven't been able to find a suitable stand for the HTC HD7 so I decided to build another custom stand from a Rosewood block.

The new stand / dock was modeled in Blender and then the 3D model was imported into Cut3d to product 3 cut files to use on our CNC mill.

Parts used are a Apple iPhone dock for the pcb and apple connectors, a surface mounting Micro USB plug and a spare usb lead which was cut then soldered to the micro usb plug on the base of the stand.

Video at end of post.

Blender 3D model screen shot

More...

Mac Pro Tower 2.5 SSD mounting brackets

The older 2008 Apple Mac Pro tower computers use a crude and prone to vibration mounting bracket system to hold the hard drives upside down in the case.

When I changed to use an Intel SSD drive last year I had to fix the drive into place with cable ties to hold it up in the apple drive trays.

Last week I ordered a Corsair Force 3 240GB solid state drive to use as a Windows 7 boot drive and use the older 160GB Intel SSD just for OSX.

Fitting the second drive with cable ties wasn't possible as the front drive bay doesn't give you any access to get the ties in place so machined some brackets from 10mm aluminium and these screw into the side of the SSD drives and into two of the mounting brackets on the Apple drive trays. Its not the best solution as the drive is only held up on one side but it allows the fitting of a 2.5" SSD drive into bays 1 and 2 on the Mac Pro (3 and 4 have 1TB 3.5" normal drives fitted)

Drilling the side mounting holes for the SSD drives

More...

Apple G5 iMac Screen Flickering and Screen Corruption

Yesterday my old G5 Apple iMac started to crash and have screen corruption with windows appearing to freeze and then leave parts behind when moving around. After a hour the computer was crashing as soon as it booted and the startup logo developed distortion and lines across the screen and ended up with the display being completely unusable.

After removing the cover on the iMac I found that 4 of the capacitors on the main logic board had expanded and blown which were located in the areas circled below.

More...

Apple Mac Pro Tower High Pitch Whine

Apple Nvidia 8800GTFrom new my Mac Pro tower has had an annoying high pitched squeal or whine when moving windows or scrolling windows on the screen.

The sound is not there all the time but only after the machine has been on for a few hours so it had to be heat related.

After spending an hour or two tracking down the sound it was coming from the Nvidia 8800GT graphics card which is fitted as standard into the Mac Pro’s.

Other blogs and forums suggested that the noise is caused by the inductors on the graphics card resonating when under load and needed to be fixed down.

After removing the graphics card and taking the heatsink cover off which was held on with cross head screws, I found several large inductors on the board.

More...

Oct11

aluminum imac hard drive upgrade guide

Aluminium iMac Hard Drive upgrade guide

Upgrading the internal hard drive in a 2007-2008 Apple iMac to 1.5TB

The following guide provides step by step instructions on how to disassemble and upgrade your Apple iMac 20" or 24" models.

Tools required:
T6 Torx Driver and T9 Torx Driver
Suction Cups for removing the glass front panel - These can be obtained from many DIY shops or online for less than £10
Philips Screwdriver for removing the memory cover.

New Hard Drive. I used a Segate 1.5TB SATA 7200 rpm model which was £140

http://vimeo.com/moogaloop.swf?clip_id=2252036

Below is a link to a HD video of the work involved in the upgrade:

Apple iMac hard drive upgrade from Brian Dorey on Vimeo.

Please note this is not an official Apple guide so proceed at your own risk!

  1. Remove the memory slot cover from the base of the machine.
  2. Using the suction cups carefully place on the glass screen cover and remove the glass panel. Place somewhere safe and clean.
  3. Remove the torx screws from the front panel surround on the edge of the LCD screen (some of the screws are different sizes)
  4. Lift the screen away from the main chassis and life up and over above the computer
  5. Remove the screws holding the LCD panel to the chassis
  6. Remove 2 screws from the LCD connector and remove the connector from the graphics card
  7. Carefully life the LCD panel from the bottom to expose the 4 small connectors for the backlight. Mark the connectors with a marker to aid reassembly and disconnect the connectors
  8. Lift the panel clear of the chassis
  9. Remove the hard drive temperate sensor and place to one side
  10. Unclip the hard drive from the chassis. This plastic bracket can be a tight fit so some force is required to remove it
  11. Remove the power and SATA connectors from the hard drive and remove from the chassis
  12. Remove the screws holding the plastic clip from the hard drive and the 2 mounting pins from the other side of the hard drive
  13. Fit the clip and pins to the new hard drive
  14. Reconnect the power and SATA connectors and clip the new hard drive back into the computer chassis
  15. Refit the LCD screen and reconnect the 4 small backlight connectors
  16. Place the LCD panel flat on the chassis and reconnect the screen connector and refit the two small screws
  17. Refit all the screws from the edge of the LCD screen
  18. Refit front panel and take care not to trap the small cable at the top of the screen
  19. Refit all the front panel screws in the same order as they where removed (some of the screws are different sizes)
  20. Clean any dust from the LCD panel and the front glass panel using a soft screen cleaning cloth (don't use compressed air as this often leaves propellant on the screen which is very hard to remove)
  21. Remove the suction cups from the screen and clean the glass.
  22. Refit the memory slot cover on the base of the machine.

Next you need to reinstall OS X from your operating system disks and then your upgraded iMac is ready to use!