Friday, September 28, 2012

Open Excel File by Double Click

Recently I had experience a problem at work. I cannot open Excel files by double click them. I tried to open from Excel Open menu and it works fine. I have no problems to open other files such as word or txt files.

I checked my other colleagues and they don't have the issue. One of my friend recommended me to find solution from web by googling. Soon I found a solution. This is something related to Excel registry settings. Since the complexity of Windows registry, it is not recommended to directly edit or change settings there. I found that there is file association from File Explorer. Here is what I did.

First, open File Type from Tools menu, locate the XLS (notice the upper case):

Click Advanced button, the following dialog is displayed.

Select Open in Action list. Click on Edit button:

Make sure to clear Use DDE, then click OK. Apply changes. This will be double click on Excel default behavior back.



Tuesday, September 11, 2012

iOS and New iPhone in Tomorrow's Special Event

Apple has been doing special event to release news about devices and software in past years. I have been kept close look at those events since I got my first iMac in 2007. Tomorrow, September 12, 2012, will be another special event.

A lots of rumors are focused on new iPhone or new hardware devices. What I am actually interested in is the formal release date of iOS 6. I have been waiting XCODE update with iOS 6 support this Fall. I have watched WWDC 2012 videos about iOS 6. I really like the new features in iOS 6, both in Objective-C and new UI components. My next app will use some of those new features.

I'll update this blog after all the news will be released in tomorrow's Apple special event. This will determine how I'll be back working on my apps.

Today, September 12, 2012, Apple made a long list of announcements. iPhone 5 looks gorgeous. The most interesting news for me is the iOS 6 release date. It will be available in one week time, next Wednesday, September 19, 2012, before iPhone 5 release (on September 21, 2012). Not sure when the XCODE update will be available.

I am still watching today's Keynote speech, 1 hour 53 minutes. First time in almost 2 hours. I think my internet has some problems, or the Apple site streaming may have issues. I had several times frozen during AirPlay Mirroring. When I went back to my iMac, I still has similar issue. The reason I suspect internet provider issue is that my QQ app lost connections several times. Anyway, I am going to back to the speech.


Sunday, September 09, 2012

Get Caller Class Context and Caller Method Names

In my MyLog class, I prefer to print class name and method name in my log messages. What I did before was to use hard coded strings. This practice makes the maintenance difficult, specially when class or method names are changed.

Later I found two nice Cocoa C-Functions to achieve the same result, without any hard-coded strings. Those functions are great way to get context class and method names. Therefore, I added them to MyClass as convenient macros:

#define CALLER_SELECTOR_NAME NSStringFromSelector(_cmd)
#define CALLER_CONTEXT       NSStringFromClass([self class])

Here are examples to use CALLER_CONEXT to initialize MyLog instance and use CALLER_SELECTOR_NAME to get method name:

// ExampleClass1.m
#import "MyLogger.h"
@property (strong, nonatomic) MyLogger* logger;
@implementation ExampleClass1
@synthesize logger;
- (MyLogger *) logger {
   if (!_logger) {
       _logger = [[MyLogger alloc] initWithContext:CALLER_CONTEXT];
   return _logger;
- (void) viewWillAppear:(BOOL)animated {
   [super viewWillAppear:animated];

   [self.logger debug:
        return [NSString stringWithFormat:@"'%@' is called!",

Here is the result in the debug console:

2012-09-09 14:23:44.990 TapToCount[5260:c07] [DEBUG] ExampleClass1 - 'viewWillAppear:' is called!



Monday, September 03, 2012

Update: MyLog with Block

I wrote a utility class to log messages in Objective-C long time ago. I updated the class with block early this year, which is similar as delegate in C#. The reason I like to use blocks is that I think, it will improve my app performance.

Here is what I did before, taking info as an example:

- (MyLogger*) info:(NSString*)messageFormat, ...;

A message string is passed to info method by using a list of dynamic string parameters. No matter if I enabled info logging level or not, the message string would be built on call.

By using a block, the string is built within a dynamic block of codes. The bock is actually a pointer to a function. The block of codes may not be executed at all if the logging level is not enabled. Therefore, I think this strategy would improve app performance.

typedef NSString* (^MessageBuildBlock_t)();
- (MyLogger*) info:(NSString* (^)(void))msgBuildBlock;

The block is defined as a function returning a string. Then the block is used as a parameter for info method.