Blog

Here is my blog place, a place  i want to leave my memory here.

How To Find Duplicate File(s) By Any Duplicate Finder

2013-05-27 15:15:21 hummersoftware
There are three steps to finde duplicates, I will demonstrate you how to find the duplicate song(s) by Any Duplicate Finder (ADF):
1.Finde the iTunes Library
It’s usually the iTunes Library locates at /Users/xxx/Music/iTunes/iTunes Media, the “xxx” is the current user’s name. Drag it to ADF to scanning path area, once you find the right iTunes Media path;
1 2
2.click scan
Then you will find the duplicate files.
3
3. chose the file(s) you want to delete, and click delete it.
PS. It’s very important to make sure your spotlight is working ok now, since ADF dependents the spotlight to find the duplicate file(s) more fast. To make sure your spotlight is ready by clicking the spotlight icon (right-top on the statu bar, pic 1), you will find the spotlight like pic 2.
   4
(pic 1)
5
(pic 2)
 
Thanks for your feedback, It’s appreciated if you can give our product a good reviews on App Store, Thanks!
Posted in: Any Duplicate FinderBlog Read more... 4 comments

Cocoa with Love: Finding or creating the application support directory

2012-09-20 01:42:43 hummersoftware

A simple post this week but one which optimizes a common task: locating the application support directory for the current application, creating it if it doesn’t exist. The result makes accessing the current application’s support directory a single line and provides a structure for locating and creating folders at other standard locations with similar ease.

The Application Support Directory

On the Mac, the correct location to store persistent user-related files for your application is in a directory with the same name as your application in the Application Support directory for the current user.

As an example, if the current user “person” runs an application named “ExampleApp” it would store such files in the following location:

/Users/person/Library/Application Support/ExampleApp/

On iPhone OS devices, the running application gets its own copy of the Library directory, so you could write files wherever you choose within this. However, I use the same code on both platforms for consistency and there is no real penalty in doing this. For an iPhone OS device then, the path to the application support directory would look like this:

/User/Applications/12345678-AAAA-BBBB-CCCC-0123456789AB/Library/Application Support/ExampleApp/

where 12345678-AAAA-BBBB-CCCC-0123456789AB is whatever UUID has been assigned to your application.

The application support directory is only for user-related persistent files. If you want to store user-related preferences, it is generally better to can store them in the NSUserDefaults.

Getting paths correctly

The correct way to get the path to the Application Support directory is to use theNSSearchPathForDirectoriesInDomains function passing NSApplicationSupportDirectory for the search path and NSUserDomainMask for the domain.

This can be done in one line but on its own, it is only ever part of the solution.

While NSSearchPathForDirectoriesInDomains can return a path to the Application Support directory, it does not guarantee that the application support directory exists. For an iPhone OS device, it almost certainly won’t exist the first time you run the application.

Further, we need to append the name of the current application to this path and create this application-specific subdirectory if needed.

Finally, we need to handle all of this in a way that is tolerant of errors including failure to create the directory or existence of files where we need a directory to go.

A simple idea — get the application support directory — turns out to be a multi-step operation.

Design of the solution

The solution that I use in many of my applications is based around a method with the following declaration:

- (NSString *)findOrCreateDirectory:(NSSearchPathDirectory)searchPathDirectory
    inDomain:(NSSearchPathDomainMask)domainMask
    appendPathComponent:(NSString *)appendComponent
    error:(NSError **)errorOut

This is a flexible method that can be used for resolving/creating a directory/subdirectory at any standard location searchable by NSSearchPathForDirectoriesInDomains.

The first two parameters are the parameters passed to NSSearchPathForDirectoriesInDomains, the third parameter is a subpath to append to the result fromNSSearchPathForDirectoriesInDomains (which we can use to append the current application’s name to get our application specific subdirectory). The final parameter is used to return information about any of the three errors that can occur (no path found, file exists at directory location or unable to create directories).

I further supplement this with a convenience method to invoke this with all the appropriate parameters for creating the application support directory:

- (NSString *)applicationSupportDirectory

On error, this method simply logs any error result using NSLog.

In my solution, both of these methods are part of a category on NSFileManager. There is no technical requirement that it be a category on NSFileManager but these methods do useNSFileManager internally and do share the same goals of providing access to directories within the filesystem. Further refinements could also add a URL version based on the NSFileManager method-URLsForDirectory:inDomains: which would make the association less arbitrary.

Implementation

I’ve omitted the creation of the error objects for space but otherwise the implementation is as follows:

- (NSString *)findOrCreateDirectory:(NSSearchPathDirectory)searchPathDirectory
    inDomain:(NSSearchPathDomainMask)domainMask
    appendPathComponent:(NSString *)appendComponent
    error:(NSError **)errorOut
{
    // Search for the path
    NSArray* paths = NSSearchPathForDirectoriesInDomains(
        searchPathDirectory,
        domainMask,
        YES);
    if ([paths count] == 0)
    {
        // *** creation and return of error object omitted for space
        return nil;
    }
    // Normally only need the first path
    NSString *resolvedPath = [paths objectAtIndex:0];
    
    if (appendComponent)
    {
        resolvedPath = [resolvedPath
            stringByAppendingPathComponent:appendComponent];
    }
    
    // Create the path if it doesn't exist
    NSError *error;
    BOOL success = [self
        createDirectoryAtPath:resolvedPath
        withIntermediateDirectories:YES
        attributes:nil
        error:&error];
    if (!success)
    {
        if (errorOut)
        {
            *errorOut = error;
        }
        return nil;
    }
    
    // If we've made it this far, we have a success
    if (errorOut)
    {
        *errorOut = nil;
    }
    return resolvedPath;
}

I’ve noted that we “Normally only need the first path“. If you pass multiple values ORed together for the domain mask (e.g. NSUserDomainMask | NSLocalDomainMask) then this assumption will not be true. If your program needs to handle multiple directories in this way, you’ll need to add appropriate handling of multiple results.

Finally, we have the implementation of the applicationSupportDirectory method:

- (NSString *)applicationSupportDirectory
{
    NSString *executableName =
        [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleExecutable"];
    NSError *error;
    NSString *result =
        [self
            findOrCreateDirectory:NSApplicationSupportDirectory
            inDomain:NSUserDomainMask
            appendPathComponent:executableName
            error:&error];
    if (error)
    {
        NSLog(@"Unable to find or create application support directory:\n%@", error);
    }
    return result;
}

As you can see, it pulls the application name out of the main bundle’s infoDictionary and uses this to create the Application Support directory.

The end result is that you can get the path to the application support directory with the following line:

NSString *path = [[NSFileManager defaultManager] applicationSupportDirectory];

Conclusion

You can download the complete category here: NSFileManager_DirectoryLocations.zip (6kb)

I like it when a task that can be unambiguously described in a simple sentence (“Get the path to the application support directory.”) is correspondingly achieved in a single line.

The code presented in this post implements a simple set of steps but since I need to do this in most applications, it is one of my most commonly used categories.

original:Cocoa with Love: Finding or creating the application support directory.

Posted in: Blog Read more... 15 comments

Enable drag files to your application's dock icon

2012-08-05 03:11:24 hummersoftware

You can enable drag files to your application’s dock icon by edit your application’s plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>CFBundleDevelopmentRegion</key>
	<string>English</string>
	<key>CFBundleDocumentTypes</key>
	<array>
		<dict>
			<key>CFBundleTypeExtensions</key>
			<array>
				<string>sdat</string>
			</array>
			<key>CFBundleTypeIconFile</key>
			<string>@ICON@</string>
			<key>CFBundleTypeMIMETypes</key>
			<array>
				<string>text/plain</string>
				<string>text/xml</string>
                                <string>text/xhtml</string>
			</array>
			<key>CFBundleTypeName</key>
			<string>Text File</string>
			<key>CFBundleTypeRole</key>
			<string>@EXECUTABLE@</string>
		        <key>LSIsAppleDefaultForType</key>
			<true/>
		</dict>
	</array>
	<key>CFBundleExecutable</key>
	<string>Qedit</string>
	<key>CFBundleGetInfoString</key>
	<string>@EXECUTABLE@ Your name</string>
	<key>CFBundleIconFile</key>
	<string>mac_QeditIcon.icns</string>
	<key>CFBundleIdentifier</key>
	<string>your qsetting domain</string>
	<key>CFBundleName</key>
	<string>@EXECUTABLE@</string>
	<key>CFBundlePackageType</key>
	<string>APPL</string>
	<key>CFBundleShortVersionString</key>
	<string>1.4</string>
	<key>CFBundleSignature</key>
	<string>!Rch</string>
</dict>
</plist>

Use the CFBundleDocumentTypes key to configure your drag in file types, so it’s so easy!

Posted in: Blog Read more... 12 comments

16 thoughts on “Blog

  1. I simply want to mention I’m beginner to weblog and definitely loved this page. Almost certainly I’m going to bookmark your blog . You definitely come with amazing posts. Thanks for revealing your web-site.

  2. Hi there very nice blog!! Man .. Excellent .. Superb .. I’ll bookmark your site and take the feeds additionally¡KI’m satisfied to seek out so many helpful information right here within the put up, we need work out more strategies on this regard, thank you for sharing. . . . . .

  3. You really make it appear really easy together with your presentation but I find this matter to be actually something which I think I would by no means understand. It sort of feels too complicated and extremely vast for me. I’m looking ahead for your subsequent submit, I will try to get the hold of it!

  4. Very good – I ought to definitely pronounce, impressed along with your site. I had no trouble navigating via all tabs and related info ended up being truly simple to do to access. I recently located what I hoped for before you know it at all. Quite unusual. Is likely to appreciate it for those that add forums or something, web website theme . a tones way for your customer to communicate. Superb task.

  5. Magnificent goods from you, man. I’ve take into account your stuff previous to and you’re simply extremely fantastic. I actually like what you have bought here, certainly like what you are stating and the way wherein you are saying it. You’re making it entertaining and you still care for to keep it smart. I can not wait to learn far more from you. This is really a great site.

  6. It is for better covet fashion cheats (https://docs.google.com/document/d/1osmb4pq2_7ydwTlSldh4uDOd4HwXgwZLjqjqyJ2tnl8) assurance.
    Often they are the healthy body covet fashion cheats they love.
    So, start downloading mobile games are first downloaded to the mostrenowned culinary world covet fashion cheats spots.
    Through expediency to elevated jackpots, regulars have cultured and
    educated to come up with joy when they have started cooperation agreement with
    your friend.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>