SlideShare ist ein Scribd-Unternehmen logo
1 von 9
Downloaden Sie, um offline zu lesen
2014/2/23

Cocoa

#23

file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy_IDConv/CocoaStudy_IDConv.html

1/9
2014/2/23

Cocoa

#23

@interface NSString ( CocoaStudy23 )
-(id) initWithData:(NSData *)data IANACharSetName:(NSString *)charSetName;
@end
@implementation NSString ( CocoaStudy23 )
-(id) initWithData:(NSData *)data IANACharSetName:(NSString *)charSetName
{
CFStringEncoding cfCharset = CFStringConvertIANACharSetNameToEncoding((CFStringRef)charSetName);
NSStringEncoding nsCharset = CFStringConvertEncodingToNSStringEncoding(cfCharset);
return [self initWithData:data encoding:nsCharset];
}
@end
@implementation AppController
-(void) awakeFromNib
{

file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy_IDConv/CocoaStudy_IDConv.html

2/9
2014/2/23

Cocoa

#23

UInt8 cString[] = { 0x82, 0xA9, 0x82, 0xC8, 0x8A, 0xBF, 0x95, 0x5C, 0 };
NSData *streamedString = [NSData dataWithBytes:(void *)&cString length:sizeof cString];
NSString *testString = [[NSString alloc]initWithData:streamedString IANACharSetName:@"Shift-JIS"];
NSLog( testString );
}

file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy_IDConv/CocoaStudy_IDConv.html

3/9
2014/2/23

Cocoa

#23

file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy_IDConv/CocoaStudy_IDConv.html

4/9
2014/2/23

Cocoa

#23

-(void) awakeFromNib
{
NSString *targetFile = @"/Users/msyk/Documents/apple-reg.pdf";
NSString *prefMIMEType = [self preferedMIMETypeFromFile:targetFile];
NSLog( prefMIMEType );
targetFile = @"file.xls";
prefMIMEType = [self preferedMIMETypeFromFile:targetFile];
NSLog( prefMIMEType );
}
- (NSString *)preferedMIMETypeFromFile:(NSString *)targetFile
{
NSString *currentFileExtension = [targetFile pathExtension];
CFStringRef uti = UTTypeCreatePreferredIdentifierForTag(
kUTTagClassFilenameExtension, (CFStringRef)currentFileExtension, NULL);
CFStringRef prefferdMIMEType = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType);
return (NSString *)prefferdMIMEType;
}

file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy_IDConv/CocoaStudy_IDConv.html

5/9
2014/2/23

Cocoa

#23

- (NSString *)preferedMIMETypeFromFile:(NSString *)targetFile
{
FSRef ref;
FSPathMakeRef ((unsigned char*)[targetFile fileSystemRepresentation], &ref, NULL);
CFDictionaryRef values = NULL;
CFStringRef attrs[] = { kLSItemContentType, kLSItemExtension, kLSItemRoleHandlerDisplayName };
CFStringRef prefferdMIMEType = NULL;
CFArrayRef attrNames = CFArrayCreate(NULL, (const void **)attrs, 3 , NULL);
if ( LSCopyItemAttributes(&ref, kLSRolesAll, attrNames, &values) == noErr ) {
CFTypeRef uti = CFDictionaryGetValue(values, kLSItemContentType);
CFStringRef extInfo = CFDictionaryGetValue(values, kLSItemExtension);
CFStringRef appInfo = CFDictionaryGetValue(values, kLSItemRoleHandlerDisplayName);
NSLog ( @"%@ -> %@ -> %@", uti, extInfo, appInfo );
prefferdMIMEType = UTTypeCopyPreferredTagWithClass( uti, kUTTagClassMIMEType );
}
if ( prefferdMIMEType == nil ) {
/* Your Own Codes */
}
return (NSString *)prefferdMIMEType;
}

file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy_IDConv/CocoaStudy_IDConv.html

6/9
2014/2/23

Cocoa

#23

file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy_IDConv/CocoaStudy_IDConv.html

7/9
2014/2/23

Cocoa

#23

struct LSItemInfoRecord {
LSItemInfoFlags flags; //調べた項目に対するフラグ情報。ビットごとに意味があるが調べるには以下の表の定義定数を使う
OSType filetype;
//ファイルタイプ
OSType creator;
//クリエイタ
CFStringRef extension; //ファイルの拡張子を示すCFStringへの参照(使用後のリリース必要)
CFStringRef iconFileName; //(未使用)
LSKindID kindID;
//(未使用)
};
typedef struct LSItemInfoRecord LSItemInfoRecord;

file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy_IDConv/CocoaStudy_IDConv.html

8/9
2014/2/23

Cocoa

#23

file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy_IDConv/CocoaStudy_IDConv.html

9/9

Weitere ähnliche Inhalte

Was ist angesagt?

Kapacitor Alert Topic handlers
Kapacitor Alert Topic handlersKapacitor Alert Topic handlers
Kapacitor Alert Topic handlersInfluxData
 
iPhone and Rails integration
iPhone and Rails integrationiPhone and Rails integration
iPhone and Rails integrationPaul Ardeleanu
 
What they don't tell you about JavaScript
What they don't tell you about JavaScriptWhat they don't tell you about JavaScript
What they don't tell you about JavaScriptRaphael Cruzeiro
 
Java program-to-calculate-area-and-circumference-of-circle
Java program-to-calculate-area-and-circumference-of-circleJava program-to-calculate-area-and-circumference-of-circle
Java program-to-calculate-area-and-circumference-of-circleUniversity of Essex
 
Raw system logs processing with hive
Raw system logs processing with hiveRaw system logs processing with hive
Raw system logs processing with hiveArpit Patil
 
MongoDB Chunks - Distribution, Splitting, and Merging
MongoDB Chunks - Distribution, Splitting, and MergingMongoDB Chunks - Distribution, Splitting, and Merging
MongoDB Chunks - Distribution, Splitting, and MergingJason Terpko
 
Silent Revolution by Max Voronoy (Senior Consultant, Engineering, Globallogic)
Silent Revolution by Max Voronoy (Senior Consultant, Engineering, Globallogic)Silent Revolution by Max Voronoy (Senior Consultant, Engineering, Globallogic)
Silent Revolution by Max Voronoy (Senior Consultant, Engineering, Globallogic)GlobalLogic Ukraine
 
Declarative Infrastructure Tools
Declarative Infrastructure Tools Declarative Infrastructure Tools
Declarative Infrastructure Tools Yulia Shcherbachova
 
A little systemtap
A little systemtapA little systemtap
A little systemtapyang bingwu
 
Roots of a quadratic equation1
Roots of a quadratic equation1Roots of a quadratic equation1
Roots of a quadratic equation1Wilson ak
 
scalable machine learning
scalable machine learningscalable machine learning
scalable machine learningSamir Bessalah
 
Time Series Meetup: Virtual Edition | July 2020
Time Series Meetup: Virtual Edition | July 2020Time Series Meetup: Virtual Edition | July 2020
Time Series Meetup: Virtual Edition | July 2020InfluxData
 
RxJS - The Reactive extensions for JavaScript
RxJS - The Reactive extensions for JavaScriptRxJS - The Reactive extensions for JavaScript
RxJS - The Reactive extensions for JavaScriptViliam Elischer
 
Bristol 2009 q1_wright_steve
Bristol 2009 q1_wright_steveBristol 2009 q1_wright_steve
Bristol 2009 q1_wright_steveObsidian Software
 
Add Some Fun to Your Functional Programming With RXJS
Add Some Fun to Your Functional Programming With RXJSAdd Some Fun to Your Functional Programming With RXJS
Add Some Fun to Your Functional Programming With RXJSRyan Anklam
 
W3C HTML5 KIG-How to write low garbage real-time javascript
W3C HTML5 KIG-How to write low garbage real-time javascriptW3C HTML5 KIG-How to write low garbage real-time javascript
W3C HTML5 KIG-How to write low garbage real-time javascriptChanghwan Yi
 
실시간 인벤트 처리
실시간 인벤트 처리실시간 인벤트 처리
실시간 인벤트 처리Byeongweon Moon
 

Was ist angesagt? (20)

Kapacitor Alert Topic handlers
Kapacitor Alert Topic handlersKapacitor Alert Topic handlers
Kapacitor Alert Topic handlers
 
iPhone and Rails integration
iPhone and Rails integrationiPhone and Rails integration
iPhone and Rails integration
 
What they don't tell you about JavaScript
What they don't tell you about JavaScriptWhat they don't tell you about JavaScript
What they don't tell you about JavaScript
 
Java program-to-calculate-area-and-circumference-of-circle
Java program-to-calculate-area-and-circumference-of-circleJava program-to-calculate-area-and-circumference-of-circle
Java program-to-calculate-area-and-circumference-of-circle
 
Raw system logs processing with hive
Raw system logs processing with hiveRaw system logs processing with hive
Raw system logs processing with hive
 
MongoDB Chunks - Distribution, Splitting, and Merging
MongoDB Chunks - Distribution, Splitting, and MergingMongoDB Chunks - Distribution, Splitting, and Merging
MongoDB Chunks - Distribution, Splitting, and Merging
 
Silent Revolution by Max Voronoy (Senior Consultant, Engineering, Globallogic)
Silent Revolution by Max Voronoy (Senior Consultant, Engineering, Globallogic)Silent Revolution by Max Voronoy (Senior Consultant, Engineering, Globallogic)
Silent Revolution by Max Voronoy (Senior Consultant, Engineering, Globallogic)
 
Data recovery using pg_filedump
Data recovery using pg_filedumpData recovery using pg_filedump
Data recovery using pg_filedump
 
Declarative Infrastructure Tools
Declarative Infrastructure Tools Declarative Infrastructure Tools
Declarative Infrastructure Tools
 
A little systemtap
A little systemtapA little systemtap
A little systemtap
 
Roots of a quadratic equation1
Roots of a quadratic equation1Roots of a quadratic equation1
Roots of a quadratic equation1
 
scalable machine learning
scalable machine learningscalable machine learning
scalable machine learning
 
Time Series Meetup: Virtual Edition | July 2020
Time Series Meetup: Virtual Edition | July 2020Time Series Meetup: Virtual Edition | July 2020
Time Series Meetup: Virtual Edition | July 2020
 
RxJS - The Reactive extensions for JavaScript
RxJS - The Reactive extensions for JavaScriptRxJS - The Reactive extensions for JavaScript
RxJS - The Reactive extensions for JavaScript
 
Java 7 new features
Java 7 new featuresJava 7 new features
Java 7 new features
 
Single qubit-gates operations
Single qubit-gates operationsSingle qubit-gates operations
Single qubit-gates operations
 
Bristol 2009 q1_wright_steve
Bristol 2009 q1_wright_steveBristol 2009 q1_wright_steve
Bristol 2009 q1_wright_steve
 
Add Some Fun to Your Functional Programming With RXJS
Add Some Fun to Your Functional Programming With RXJSAdd Some Fun to Your Functional Programming With RXJS
Add Some Fun to Your Functional Programming With RXJS
 
W3C HTML5 KIG-How to write low garbage real-time javascript
W3C HTML5 KIG-How to write low garbage real-time javascriptW3C HTML5 KIG-How to write low garbage real-time javascript
W3C HTML5 KIG-How to write low garbage real-time javascript
 
실시간 인벤트 처리
실시간 인벤트 처리실시간 인벤트 처리
실시간 인벤트 처리
 

Andere mochten auch

Ruby Meets Cocoa
Ruby Meets CocoaRuby Meets Cocoa
Ruby Meets CocoaRobbert
 
Yet Another Max/MSP-Cocoa Communication
Yet Another Max/MSP-Cocoa CommunicationYet Another Max/MSP-Cocoa Communication
Yet Another Max/MSP-Cocoa CommunicationNao Tokui
 
The Dark Depths of iOS [CodeMash 2011]
The Dark Depths of iOS [CodeMash 2011]The Dark Depths of iOS [CodeMash 2011]
The Dark Depths of iOS [CodeMash 2011]Chris Adamson
 
Core MIDI and Friends
Core MIDI and FriendsCore MIDI and Friends
Core MIDI and FriendsChris Adamson
 
Objective-C Survives
Objective-C SurvivesObjective-C Survives
Objective-C SurvivesS Akai
 

Andere mochten auch (6)

Ruby Meets Cocoa
Ruby Meets CocoaRuby Meets Cocoa
Ruby Meets Cocoa
 
Yet Another Max/MSP-Cocoa Communication
Yet Another Max/MSP-Cocoa CommunicationYet Another Max/MSP-Cocoa Communication
Yet Another Max/MSP-Cocoa Communication
 
The Dark Depths of iOS [CodeMash 2011]
The Dark Depths of iOS [CodeMash 2011]The Dark Depths of iOS [CodeMash 2011]
The Dark Depths of iOS [CodeMash 2011]
 
Core MIDI and Friends
Core MIDI and FriendsCore MIDI and Friends
Core MIDI and Friends
 
Objective-C Survives
Objective-C SurvivesObjective-C Survives
Objective-C Survives
 
Cocoa fundamentalswert
Cocoa fundamentalswertCocoa fundamentalswert
Cocoa fundamentalswert
 

Ähnlich wie Get File MIME Type From Extension in Cocoa

High Performance Core Data
High Performance Core DataHigh Performance Core Data
High Performance Core DataMatthew Morey
 
Store and Process Big Data with Hadoop and Cassandra
Store and Process Big Data with Hadoop and CassandraStore and Process Big Data with Hadoop and Cassandra
Store and Process Big Data with Hadoop and CassandraDeependra Ariyadewa
 
Using Spark to Load Oracle Data into Cassandra
Using Spark to Load Oracle Data into CassandraUsing Spark to Load Oracle Data into Cassandra
Using Spark to Load Oracle Data into CassandraJim Hatcher
 
Using Spark to Load Oracle Data into Cassandra (Jim Hatcher, IHS Markit) | C*...
Using Spark to Load Oracle Data into Cassandra (Jim Hatcher, IHS Markit) | C*...Using Spark to Load Oracle Data into Cassandra (Jim Hatcher, IHS Markit) | C*...
Using Spark to Load Oracle Data into Cassandra (Jim Hatcher, IHS Markit) | C*...DataStax
 
Cloudcamp scotland - Using cloud without losing control
Cloudcamp scotland - Using cloud without losing controlCloudcamp scotland - Using cloud without losing control
Cloudcamp scotland - Using cloud without losing controlDuncan Johnston-Watt
 
TensorFlow BASTA2018 Machinelearning
TensorFlow BASTA2018 MachinelearningTensorFlow BASTA2018 Machinelearning
TensorFlow BASTA2018 MachinelearningMax Kleiner
 
Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Get the Most Out of iOS 11 with Visual Studio Tools for XamarinGet the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Get the Most Out of iOS 11 with Visual Studio Tools for XamarinXamarin
 
Using spark 1.2 with Java 8 and Cassandra
Using spark 1.2 with Java 8 and CassandraUsing spark 1.2 with Java 8 and Cassandra
Using spark 1.2 with Java 8 and CassandraDenis Dus
 
Config interface
Config interfaceConfig interface
Config interfaceRyan Boland
 
MySQL flexible schema and JSON for Internet of Things
MySQL flexible schema and JSON for Internet of ThingsMySQL flexible schema and JSON for Internet of Things
MySQL flexible schema and JSON for Internet of ThingsAlexander Rubin
 
Migrating Babel from CommonJS to ESM
Migrating Babel     from CommonJS to ESMMigrating Babel     from CommonJS to ESM
Migrating Babel from CommonJS to ESMIgalia
 
Productionalizing spark streaming applications
Productionalizing spark streaming applicationsProductionalizing spark streaming applications
Productionalizing spark streaming applicationsRobert Sanders
 
Alexander Pavlenko, Senior Java Developer, "Cassandra into"
Alexander Pavlenko, Senior Java Developer, "Cassandra into"Alexander Pavlenko, Senior Java Developer, "Cassandra into"
Alexander Pavlenko, Senior Java Developer, "Cassandra into"Alina Vilk
 
Cassandra into
Cassandra intoCassandra into
Cassandra intoDataArt
 
Cascading Through Hadoop for the Boulder JUG
Cascading Through Hadoop for the Boulder JUGCascading Through Hadoop for the Boulder JUG
Cascading Through Hadoop for the Boulder JUGMatthew McCullough
 
DOSUG Taking Apache Camel For A Ride
DOSUG Taking Apache Camel For A RideDOSUG Taking Apache Camel For A Ride
DOSUG Taking Apache Camel For A RideMatthew McCullough
 
Modern Android app library stack
Modern Android app library stackModern Android app library stack
Modern Android app library stackTomáš Kypta
 
Tomcat连接池配置方法V2.1
Tomcat连接池配置方法V2.1Tomcat连接池配置方法V2.1
Tomcat连接池配置方法V2.1Zianed Hou
 

Ähnlich wie Get File MIME Type From Extension in Cocoa (20)

High Performance Core Data
High Performance Core DataHigh Performance Core Data
High Performance Core Data
 
Store and Process Big Data with Hadoop and Cassandra
Store and Process Big Data with Hadoop and CassandraStore and Process Big Data with Hadoop and Cassandra
Store and Process Big Data with Hadoop and Cassandra
 
I os 13
I os 13I os 13
I os 13
 
Using Spark to Load Oracle Data into Cassandra
Using Spark to Load Oracle Data into CassandraUsing Spark to Load Oracle Data into Cassandra
Using Spark to Load Oracle Data into Cassandra
 
Using Spark to Load Oracle Data into Cassandra (Jim Hatcher, IHS Markit) | C*...
Using Spark to Load Oracle Data into Cassandra (Jim Hatcher, IHS Markit) | C*...Using Spark to Load Oracle Data into Cassandra (Jim Hatcher, IHS Markit) | C*...
Using Spark to Load Oracle Data into Cassandra (Jim Hatcher, IHS Markit) | C*...
 
Cloudcamp scotland - Using cloud without losing control
Cloudcamp scotland - Using cloud without losing controlCloudcamp scotland - Using cloud without losing control
Cloudcamp scotland - Using cloud without losing control
 
TensorFlow BASTA2018 Machinelearning
TensorFlow BASTA2018 MachinelearningTensorFlow BASTA2018 Machinelearning
TensorFlow BASTA2018 Machinelearning
 
Map kit light
Map kit lightMap kit light
Map kit light
 
Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Get the Most Out of iOS 11 with Visual Studio Tools for XamarinGet the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
 
Using spark 1.2 with Java 8 and Cassandra
Using spark 1.2 with Java 8 and CassandraUsing spark 1.2 with Java 8 and Cassandra
Using spark 1.2 with Java 8 and Cassandra
 
Config interface
Config interfaceConfig interface
Config interface
 
MySQL flexible schema and JSON for Internet of Things
MySQL flexible schema and JSON for Internet of ThingsMySQL flexible schema and JSON for Internet of Things
MySQL flexible schema and JSON for Internet of Things
 
Migrating Babel from CommonJS to ESM
Migrating Babel     from CommonJS to ESMMigrating Babel     from CommonJS to ESM
Migrating Babel from CommonJS to ESM
 
Productionalizing spark streaming applications
Productionalizing spark streaming applicationsProductionalizing spark streaming applications
Productionalizing spark streaming applications
 
Alexander Pavlenko, Senior Java Developer, "Cassandra into"
Alexander Pavlenko, Senior Java Developer, "Cassandra into"Alexander Pavlenko, Senior Java Developer, "Cassandra into"
Alexander Pavlenko, Senior Java Developer, "Cassandra into"
 
Cassandra into
Cassandra intoCassandra into
Cassandra into
 
Cascading Through Hadoop for the Boulder JUG
Cascading Through Hadoop for the Boulder JUGCascading Through Hadoop for the Boulder JUG
Cascading Through Hadoop for the Boulder JUG
 
DOSUG Taking Apache Camel For A Ride
DOSUG Taking Apache Camel For A RideDOSUG Taking Apache Camel For A Ride
DOSUG Taking Apache Camel For A Ride
 
Modern Android app library stack
Modern Android app library stackModern Android app library stack
Modern Android app library stack
 
Tomcat连接池配置方法V2.1
Tomcat连接池配置方法V2.1Tomcat连接池配置方法V2.1
Tomcat连接池配置方法V2.1
 

Mehr von Masayuki Nii

Framework Enabling End-Users to Maintain Web Applications (ICICWS2015)
Framework Enabling End-Users to Maintain Web Applications (ICICWS2015)Framework Enabling End-Users to Maintain Web Applications (ICICWS2015)
Framework Enabling End-Users to Maintain Web Applications (ICICWS2015)Masayuki Nii
 
トップエスイー勉強会2014第1回-INTER-Mediator
トップエスイー勉強会2014第1回-INTER-Mediatorトップエスイー勉強会2014第1回-INTER-Mediator
トップエスイー勉強会2014第1回-INTER-MediatorMasayuki Nii
 
Cocoa勉強会#62-新しい通信クラス群NSURLSessionを使ってみる
Cocoa勉強会#62-新しい通信クラス群NSURLSessionを使ってみるCocoa勉強会#62-新しい通信クラス群NSURLSessionを使ってみる
Cocoa勉強会#62-新しい通信クラス群NSURLSessionを使ってみるMasayuki Nii
 
Cocoa勉強会#34-iPhoneでタブバーを非表示に無理矢理する方法
Cocoa勉強会#34-iPhoneでタブバーを非表示に無理矢理する方法Cocoa勉強会#34-iPhoneでタブバーを非表示に無理矢理する方法
Cocoa勉強会#34-iPhoneでタブバーを非表示に無理矢理する方法Masayuki Nii
 
Cocoa勉強会#61-メインスレッド外でNSURLConnection
Cocoa勉強会#61-メインスレッド外でNSURLConnectionCocoa勉強会#61-メインスレッド外でNSURLConnection
Cocoa勉強会#61-メインスレッド外でNSURLConnectionMasayuki Nii
 
Cocoa勉強会#23-カスタムシートとModality
Cocoa勉強会#23-カスタムシートとModalityCocoa勉強会#23-カスタムシートとModality
Cocoa勉強会#23-カスタムシートとModalityMasayuki Nii
 
Cocoa勉強会#6-SQLiteをCocoaで使う
Cocoa勉強会#6-SQLiteをCocoaで使うCocoa勉強会#6-SQLiteをCocoaで使う
Cocoa勉強会#6-SQLiteをCocoaで使うMasayuki Nii
 
Cocoa勉強会#60-Common Cryptoを使った共通鍵の暗号と復号
Cocoa勉強会#60-Common Cryptoを使った共通鍵の暗号と復号Cocoa勉強会#60-Common Cryptoを使った共通鍵の暗号と復号
Cocoa勉強会#60-Common Cryptoを使った共通鍵の暗号と復号Masayuki Nii
 
Cocoa勉強会#57-Baseによるローカライズまとめ
Cocoa勉強会#57-BaseによるローカライズまとめCocoa勉強会#57-Baseによるローカライズまとめ
Cocoa勉強会#57-BaseによるローカライズまとめMasayuki Nii
 
Cocoa勉強会#56-小ネタ集あなたの常識はすでに通用しない
Cocoa勉強会#56-小ネタ集あなたの常識はすでに通用しないCocoa勉強会#56-小ネタ集あなたの常識はすでに通用しない
Cocoa勉強会#56-小ネタ集あなたの常識はすでに通用しないMasayuki Nii
 
Cocoa勉強会#45-AWS SimpleDBを使ってみる
Cocoa勉強会#45-AWS SimpleDBを使ってみるCocoa勉強会#45-AWS SimpleDBを使ってみる
Cocoa勉強会#45-AWS SimpleDBを使ってみるMasayuki Nii
 
Cocoa勉強会#36-iPhone OS 3.0で変更されたテーブルビュー
Cocoa勉強会#36-iPhone OS 3.0で変更されたテーブルビューCocoa勉強会#36-iPhone OS 3.0で変更されたテーブルビュー
Cocoa勉強会#36-iPhone OS 3.0で変更されたテーブルビューMasayuki Nii
 
Cocoa勉強会#33-意外に楽に使えるlibcurl
Cocoa勉強会#33-意外に楽に使えるlibcurlCocoa勉強会#33-意外に楽に使えるlibcurl
Cocoa勉強会#33-意外に楽に使えるlibcurlMasayuki Nii
 
Cocoa勉強会#28-OpenSSLで暗号化したファイルを復号する
Cocoa勉強会#28-OpenSSLで暗号化したファイルを復号するCocoa勉強会#28-OpenSSLで暗号化したファイルを復号する
Cocoa勉強会#28-OpenSSLで暗号化したファイルを復号するMasayuki Nii
 
Cocoa勉強会#27-QuickLookプラグインの作り方
Cocoa勉強会#27-QuickLookプラグインの作り方Cocoa勉強会#27-QuickLookプラグインの作り方
Cocoa勉強会#27-QuickLookプラグインの作り方Masayuki Nii
 
Cocoa勉強会#37-シェイクイベントの実装
Cocoa勉強会#37-シェイクイベントの実装Cocoa勉強会#37-シェイクイベントの実装
Cocoa勉強会#37-シェイクイベントの実装Masayuki Nii
 
Cocoa勉強会#32-表形式のデータに順序を記録する方法
Cocoa勉強会#32-表形式のデータに順序を記録する方法Cocoa勉強会#32-表形式のデータに順序を記録する方法
Cocoa勉強会#32-表形式のデータに順序を記録する方法Masayuki Nii
 
Cocoa勉強会#35-iPhoneでのコピペとカスタムUI
Cocoa勉強会#35-iPhoneでのコピペとカスタムUICocoa勉強会#35-iPhoneでのコピペとカスタムUI
Cocoa勉強会#35-iPhoneでのコピペとカスタムUIMasayuki Nii
 
Cocoa勉強会#47-NSURLConnectionのデリゲートメソッドと認証
Cocoa勉強会#47-NSURLConnectionのデリゲートメソッドと認証Cocoa勉強会#47-NSURLConnectionのデリゲートメソッドと認証
Cocoa勉強会#47-NSURLConnectionのデリゲートメソッドと認証Masayuki Nii
 
Cocoa勉強会#38-UITableViewテーブル内のナビゲーション
Cocoa勉強会#38-UITableViewテーブル内のナビゲーションCocoa勉強会#38-UITableViewテーブル内のナビゲーション
Cocoa勉強会#38-UITableViewテーブル内のナビゲーションMasayuki Nii
 

Mehr von Masayuki Nii (20)

Framework Enabling End-Users to Maintain Web Applications (ICICWS2015)
Framework Enabling End-Users to Maintain Web Applications (ICICWS2015)Framework Enabling End-Users to Maintain Web Applications (ICICWS2015)
Framework Enabling End-Users to Maintain Web Applications (ICICWS2015)
 
トップエスイー勉強会2014第1回-INTER-Mediator
トップエスイー勉強会2014第1回-INTER-Mediatorトップエスイー勉強会2014第1回-INTER-Mediator
トップエスイー勉強会2014第1回-INTER-Mediator
 
Cocoa勉強会#62-新しい通信クラス群NSURLSessionを使ってみる
Cocoa勉強会#62-新しい通信クラス群NSURLSessionを使ってみるCocoa勉強会#62-新しい通信クラス群NSURLSessionを使ってみる
Cocoa勉強会#62-新しい通信クラス群NSURLSessionを使ってみる
 
Cocoa勉強会#34-iPhoneでタブバーを非表示に無理矢理する方法
Cocoa勉強会#34-iPhoneでタブバーを非表示に無理矢理する方法Cocoa勉強会#34-iPhoneでタブバーを非表示に無理矢理する方法
Cocoa勉強会#34-iPhoneでタブバーを非表示に無理矢理する方法
 
Cocoa勉強会#61-メインスレッド外でNSURLConnection
Cocoa勉強会#61-メインスレッド外でNSURLConnectionCocoa勉強会#61-メインスレッド外でNSURLConnection
Cocoa勉強会#61-メインスレッド外でNSURLConnection
 
Cocoa勉強会#23-カスタムシートとModality
Cocoa勉強会#23-カスタムシートとModalityCocoa勉強会#23-カスタムシートとModality
Cocoa勉強会#23-カスタムシートとModality
 
Cocoa勉強会#6-SQLiteをCocoaで使う
Cocoa勉強会#6-SQLiteをCocoaで使うCocoa勉強会#6-SQLiteをCocoaで使う
Cocoa勉強会#6-SQLiteをCocoaで使う
 
Cocoa勉強会#60-Common Cryptoを使った共通鍵の暗号と復号
Cocoa勉強会#60-Common Cryptoを使った共通鍵の暗号と復号Cocoa勉強会#60-Common Cryptoを使った共通鍵の暗号と復号
Cocoa勉強会#60-Common Cryptoを使った共通鍵の暗号と復号
 
Cocoa勉強会#57-Baseによるローカライズまとめ
Cocoa勉強会#57-BaseによるローカライズまとめCocoa勉強会#57-Baseによるローカライズまとめ
Cocoa勉強会#57-Baseによるローカライズまとめ
 
Cocoa勉強会#56-小ネタ集あなたの常識はすでに通用しない
Cocoa勉強会#56-小ネタ集あなたの常識はすでに通用しないCocoa勉強会#56-小ネタ集あなたの常識はすでに通用しない
Cocoa勉強会#56-小ネタ集あなたの常識はすでに通用しない
 
Cocoa勉強会#45-AWS SimpleDBを使ってみる
Cocoa勉強会#45-AWS SimpleDBを使ってみるCocoa勉強会#45-AWS SimpleDBを使ってみる
Cocoa勉強会#45-AWS SimpleDBを使ってみる
 
Cocoa勉強会#36-iPhone OS 3.0で変更されたテーブルビュー
Cocoa勉強会#36-iPhone OS 3.0で変更されたテーブルビューCocoa勉強会#36-iPhone OS 3.0で変更されたテーブルビュー
Cocoa勉強会#36-iPhone OS 3.0で変更されたテーブルビュー
 
Cocoa勉強会#33-意外に楽に使えるlibcurl
Cocoa勉強会#33-意外に楽に使えるlibcurlCocoa勉強会#33-意外に楽に使えるlibcurl
Cocoa勉強会#33-意外に楽に使えるlibcurl
 
Cocoa勉強会#28-OpenSSLで暗号化したファイルを復号する
Cocoa勉強会#28-OpenSSLで暗号化したファイルを復号するCocoa勉強会#28-OpenSSLで暗号化したファイルを復号する
Cocoa勉強会#28-OpenSSLで暗号化したファイルを復号する
 
Cocoa勉強会#27-QuickLookプラグインの作り方
Cocoa勉強会#27-QuickLookプラグインの作り方Cocoa勉強会#27-QuickLookプラグインの作り方
Cocoa勉強会#27-QuickLookプラグインの作り方
 
Cocoa勉強会#37-シェイクイベントの実装
Cocoa勉強会#37-シェイクイベントの実装Cocoa勉強会#37-シェイクイベントの実装
Cocoa勉強会#37-シェイクイベントの実装
 
Cocoa勉強会#32-表形式のデータに順序を記録する方法
Cocoa勉強会#32-表形式のデータに順序を記録する方法Cocoa勉強会#32-表形式のデータに順序を記録する方法
Cocoa勉強会#32-表形式のデータに順序を記録する方法
 
Cocoa勉強会#35-iPhoneでのコピペとカスタムUI
Cocoa勉強会#35-iPhoneでのコピペとカスタムUICocoa勉強会#35-iPhoneでのコピペとカスタムUI
Cocoa勉強会#35-iPhoneでのコピペとカスタムUI
 
Cocoa勉強会#47-NSURLConnectionのデリゲートメソッドと認証
Cocoa勉強会#47-NSURLConnectionのデリゲートメソッドと認証Cocoa勉強会#47-NSURLConnectionのデリゲートメソッドと認証
Cocoa勉強会#47-NSURLConnectionのデリゲートメソッドと認証
 
Cocoa勉強会#38-UITableViewテーブル内のナビゲーション
Cocoa勉強会#38-UITableViewテーブル内のナビゲーションCocoa勉強会#38-UITableViewテーブル内のナビゲーション
Cocoa勉強会#38-UITableViewテーブル内のナビゲーション
 

Kürzlich hochgeladen

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 

Kürzlich hochgeladen (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 

Get File MIME Type From Extension in Cocoa

  • 2. 2014/2/23 Cocoa #23 @interface NSString ( CocoaStudy23 ) -(id) initWithData:(NSData *)data IANACharSetName:(NSString *)charSetName; @end @implementation NSString ( CocoaStudy23 ) -(id) initWithData:(NSData *)data IANACharSetName:(NSString *)charSetName { CFStringEncoding cfCharset = CFStringConvertIANACharSetNameToEncoding((CFStringRef)charSetName); NSStringEncoding nsCharset = CFStringConvertEncodingToNSStringEncoding(cfCharset); return [self initWithData:data encoding:nsCharset]; } @end @implementation AppController -(void) awakeFromNib { file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy_IDConv/CocoaStudy_IDConv.html 2/9
  • 3. 2014/2/23 Cocoa #23 UInt8 cString[] = { 0x82, 0xA9, 0x82, 0xC8, 0x8A, 0xBF, 0x95, 0x5C, 0 }; NSData *streamedString = [NSData dataWithBytes:(void *)&cString length:sizeof cString]; NSString *testString = [[NSString alloc]initWithData:streamedString IANACharSetName:@"Shift-JIS"]; NSLog( testString ); } file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy_IDConv/CocoaStudy_IDConv.html 3/9
  • 5. 2014/2/23 Cocoa #23 -(void) awakeFromNib { NSString *targetFile = @"/Users/msyk/Documents/apple-reg.pdf"; NSString *prefMIMEType = [self preferedMIMETypeFromFile:targetFile]; NSLog( prefMIMEType ); targetFile = @"file.xls"; prefMIMEType = [self preferedMIMETypeFromFile:targetFile]; NSLog( prefMIMEType ); } - (NSString *)preferedMIMETypeFromFile:(NSString *)targetFile { NSString *currentFileExtension = [targetFile pathExtension]; CFStringRef uti = UTTypeCreatePreferredIdentifierForTag( kUTTagClassFilenameExtension, (CFStringRef)currentFileExtension, NULL); CFStringRef prefferdMIMEType = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType); return (NSString *)prefferdMIMEType; } file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy_IDConv/CocoaStudy_IDConv.html 5/9
  • 6. 2014/2/23 Cocoa #23 - (NSString *)preferedMIMETypeFromFile:(NSString *)targetFile { FSRef ref; FSPathMakeRef ((unsigned char*)[targetFile fileSystemRepresentation], &ref, NULL); CFDictionaryRef values = NULL; CFStringRef attrs[] = { kLSItemContentType, kLSItemExtension, kLSItemRoleHandlerDisplayName }; CFStringRef prefferdMIMEType = NULL; CFArrayRef attrNames = CFArrayCreate(NULL, (const void **)attrs, 3 , NULL); if ( LSCopyItemAttributes(&ref, kLSRolesAll, attrNames, &values) == noErr ) { CFTypeRef uti = CFDictionaryGetValue(values, kLSItemContentType); CFStringRef extInfo = CFDictionaryGetValue(values, kLSItemExtension); CFStringRef appInfo = CFDictionaryGetValue(values, kLSItemRoleHandlerDisplayName); NSLog ( @"%@ -> %@ -> %@", uti, extInfo, appInfo ); prefferdMIMEType = UTTypeCopyPreferredTagWithClass( uti, kUTTagClassMIMEType ); } if ( prefferdMIMEType == nil ) { /* Your Own Codes */ } return (NSString *)prefferdMIMEType; } file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy_IDConv/CocoaStudy_IDConv.html 6/9
  • 8. 2014/2/23 Cocoa #23 struct LSItemInfoRecord { LSItemInfoFlags flags; //調べた項目に対するフラグ情報。ビットごとに意味があるが調べるには以下の表の定義定数を使う OSType filetype; //ファイルタイプ OSType creator; //クリエイタ CFStringRef extension; //ファイルの拡張子を示すCFStringへの参照(使用後のリリース必要) CFStringRef iconFileName; //(未使用) LSKindID kindID; //(未使用) }; typedef struct LSItemInfoRecord LSItemInfoRecord; file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy_IDConv/CocoaStudy_IDConv.html 8/9