2013-03-14 67 views
0

我想用客觀C. 我搜索了很多得到在Mac系統中的信息,但通過沒有了一行代碼爲 我使用。他們提供的解決方案javascript,但我希望他們在 目標C. 爲我提供一些幫助。如何得到默認瀏覽器的版本在我的Mac OS X

+0

什麼樣的制度信息? – 2013-03-14 09:00:50

+0

它像當前用戶,工作組,我自己的系統的ip.Default brwser是其中之一 – Dhiraj 2013-03-14 10:36:34

回答

0

這是測試和工程以及

 NSWorkspace *nsSharedWorkspace = [NSWorkspace sharedWorkspace]; 
     NSString *nsAppPath = [nsSharedWorkspace fullPathForApplication:appName]; 
     NSBundle *nsAppBundle = [NSBundle bundleWithPath: nsAppPath]; 
     NSDictionary *nsAppInfo = [nsAppBundle infoDictionary]; 

//Now you can print all dictionary to view all its contents and pick which you want 
     NSLog(@"%@",nsAppInfo); 

//or you can get directly using following methods 
     NSLog(@"%@",[nsAppInfo objectForKey:@"CFBundleShortVersionString"]); 
     NSLog(@"%@",[nsAppInfo objectForKey:@"CFBundleVersion"]); 

不要忘記添加了AppKit框架

2

您可以使用啓動服務來獲得路徑默認瀏覽器,如下

LSGetApplicationForURL((CFURLRef)[NSURL URLWithString: @"http:"], 
           kLSRolesAll, NULL, (CFURLRef *)&appURL); 

NSString *infoPlistPath = [[appURL path] stringByAppendingPathComponent:@"Contents/info.plist"]; 

現在宣讀了info.plist中的CFBundleShortVersionString。

0

在這裏你去:

NSString *userName=NSUserName(); 
NSLog(@"UserName: %@",userName); 

NSArray *ipAddress=[[NSHost currentHost] addresses]; 
NSLog(@"IP Address=%@",ipAddress[0]); 

更新我的回答

相關問題