Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Apr 9, 2007, 04:15 AM   #1
Soulstorm
macrumors 68000
 
Soulstorm's Avatar
 
Join Date: Feb 2005
Adding A Version Check System Into A Cocoa App

I have made an application written in Cocoa, and I would like to implement a function to check wether there is a newer version of my program available on the internet or not.

I have already a personal web spase available. So, my question is: what can I do to add this function, what frameworks or Cocoa classes must I use, and what method should I try to implement?
Soulstorm is offline   0 Reply With Quote
Old Apr 9, 2007, 04:24 AM   #2
Nutter
macrumors 6502
 
Join Date: Mar 2005
Location: London, England
There are several days of doing this. The way I'd do it is to put an XML file on your web space containing details of the latest version and a link to the download page, and load this file each time your app launches.

This is very easy to do with NSDictionary's dictionaryWithContentsOfURL: class method.
Nutter is offline   0 Reply With Quote
Old Apr 9, 2007, 04:27 AM   #3
Soulstorm
Thread Starter
macrumors 68000
 
Soulstorm's Avatar
 
Join Date: Feb 2005
XML.. hm... I hadn't thought of that. But I really don't know what is XML exactly, or how to use it. Have you got any guide or online documentation to give me? And why XML? Why not a simple text file?
Soulstorm is offline   0 Reply With Quote
Old Apr 9, 2007, 05:03 AM   #4
semaja2
macrumors 6502a
 
Join Date: Dec 2005
Location: Adelaide
Send a message via MSN to semaja2
Please do us a favour and dont create your own system, if you want one use Sparkle or Sparkle Plus

It is VERY easy to implement and if more people use such a system then it is easier for other apps to come along and do a whole system update (Instead of using sites like MacUpdate)

People also are familiar with Sparkle (Adium, etc)
__________________
InsomniaX | WiFiScriptor | Utility Lock
semaja2 is offline   0 Reply With Quote
Old Apr 9, 2007, 05:20 AM   #5
tominated
macrumors 68000
 
tominated's Avatar
 
Join Date: Jul 2006
Location: Queensland, Australia
get sparkle. It is a cocoa updating system (framework really) that uses appcasts
__________________
20" iMac Core Duo
13" 2.26Ghz MBP
Upgraded to 4GB RAM & 500GB HDD
tominated is offline   0 Reply With Quote
Old Apr 9, 2007, 05:35 AM   #6
Nutter
macrumors 6502
 
Join Date: Mar 2005
Location: London, England
As others have said, Sparkle looks good, and does all the hard work for the user. However, there's no harm in doing it the way I said, and it's good to know how.

You could use a simple text file, but an XML file essentially lets you serialise a dictionary object that contains the version number, download URL and any other information that you need (including details of pirated registration codes if you want!). This makes it easy for your app to parse the information, because the XML format is already understood by the foundation classes.

In fact, an XML file IS just a text file, just with special tags to give it a property-value structure. You can create an XML file with any text editor, or (more easily) using Property List Editor.

This is worth looking into - knowing a bit about property lists is a pretty essential skill for a Cocoa developer.
Nutter is offline   0 Reply With Quote
Old Apr 9, 2007, 05:40 AM   #7
Nutter
macrumors 6502
 
Join Date: Mar 2005
Location: London, England
Property List Programming Guide for Cocoa
Nutter is offline   0 Reply With Quote
Old Apr 9, 2007, 06:54 AM   #8
Eraserhead
macrumors G4
 
Eraserhead's Avatar
 
Join Date: Nov 2005
Location: UK
Sparkle Plus looks good, I think I might give it a try in my application (I currently use Sparkle), but that's for a later point, anyhow Sparkle support is really easy to add once you've mastered writing the XML for the RSS feed it's pretty easy. Why reinvent the wheel with your own system?

Anyway Sparkle can be downloaded here.

My RSS feed (Appcast) that I use with Sparkle is attached to this post, feel free to modify it for your own purposes, (though I'm not responsible if it doesn't work.). Though there is pretty good documentation in the download for sparkle itself that took the longest to figure out.

Note that to get it to work you'll need to remove the .txt extension and just call it appcast.xml.
Attached Files
File Type: txt appcast.xml.txt (6.1 KB, 48 views)

Last edited by Eraserhead; Apr 9, 2007 at 07:00 AM.
Eraserhead is offline   0 Reply With Quote
Old Apr 9, 2007, 01:38 PM   #9
kainjow
Moderator emeritus
 
kainjow's Avatar
 
Join Date: Jun 2000
Quote:
Originally Posted by Soulstorm View Post
XML.. hm... I hadn't thought of that. But I really don't know what is XML exactly, or how to use it. Have you got any guide or online documentation to give me? And why XML? Why not a simple text file?
XML describes data in a file. Writing your own text file format is just redoing XML. If you don't know XML, go to the library and pick up a book on it, and then come back here and download Sparkle
kainjow is offline   0 Reply With Quote
Old Apr 9, 2007, 10:10 PM   #10
HiRez
macrumors 601
 
HiRez's Avatar
 
Join Date: Jan 2004
Location: Western US
Sparkle looks good but just in case you wanted to keep it really simple, here is some old code I wrote to just check a text file. I put it in my app controller's +initialize method. It's very crude, but it works. All that's in the file is simply the version number, that's it.
Code:
+ (void)initialize {
	/* first check for new version (will be nil if no active internet connection) */
	NSString *latestVersionString = [NSString stringWithContentsOfURL:RB_NEKOTESTER_VERSION_URL];
	if (latestVersionString != nil && ![latestVersionString isEqualToString:@""] && ![latestVersionString isEqualToString:RB_NEKOTESTER_READABLE_VERSION]) {
		int choice = 0;
		NSString *msg = [NSString stringWithFormat:@"There appears to be a newer version (%@) of NekoTester available for download. Most likely it's better than this mangy old code. Would you like to get it now?", latestVersionString];
		choice = NSRunAlertPanel(@"New Version Available!", msg, @"Get It Now", @"Later", nil);
		if (choice == 1) {
			/* get now (open download URL and quit) */
			[[NSWorkspace sharedWorkspace] openURL:RB_NEKOTESTER_DOWNLOAD_URL];
			[NSApp terminate:nil];
		} else if (choice == 0) {
			/* get later (do nothing, continue execution) */
		}
	}
}
EDIT: removed some unimportant lines from the code.
__________________
Go outside, the graphics are amazing!

Last edited by HiRez; Apr 10, 2007 at 01:32 AM.
HiRez is offline   0 Reply With Quote
Old Apr 10, 2007, 02:43 AM   #11
caveman_uk
Guest
 
caveman_uk's Avatar
 
Join Date: Feb 2003
Location: Hitchin, Herts, UK
One nice thing (amongst the many) about Sparkle is that it handles beta versions well. So if you're beta testers are using say 1.4b2 but the appcast says the latest version is 1.4, Sparkle knows 1.4b2 is later than 1.4 and doesn't give the 'new version' message to the beta testers.
caveman_uk is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
How to check log files to date/time system RAM was changed? Any way to check this? asterix2k10 OS X 1 Mar 7, 2014 08:19 PM
TextEdit adding a word to its spell check! peewee12345 OS X 2 May 21, 2013 11:18 AM
Drafts Updated to Version 3.0, Adding Deeper Organization and New Actions MacRumors iOS Blog Discussion 11 Apr 25, 2013 12:34 AM
iPad: Moving saved data from an app's iPhone version to its iPad version. ziggyonice Jailbreaks and iOS Hacks 7 Mar 4, 2013 01:38 AM
Can i check if visitors are seeing older version of site? sk3pt1c Web Design and Development 2 Nov 21, 2012 10:27 AM

Forum Jump

All times are GMT -5. The time now is 04:15 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC