SlideShare ist ein Scribd-Unternehmen logo
1 von 48
iPhone SDK



iPhone
iPhone SDK




h"p://kishikawakatsumi.com

Twi"er
@k_katsumi

24/7
twenty‐four
seven
h"p://d.hatena.ne.jp/KishikawaKatsumi/
iPhone SDK


•      
touch   •          
on
the
WEB

•LDR
touch      •
•               •i‐Radio
•LCD
Clock      •
•Subway
Map     •
•MyWebClip
•               •
iPhone SDK

http://github.com/kishikawakatsumi

•hatena‐touch        •DescripMonBuilder
•ldr‐touch           •TiledLayerView
•tv‐lisMngs          •UICCalendarPicker
•MapKit‐Route‐DirecMons
•FlipCardNavigaMonView
•PhotoFlipCardView
iPhone SDK
iPhone SDK



iPhone
iPhone SDK
iPhone SDK



    (SQLite? CoreData? and so on...)


•
•
iPhone SDK

                   Library

Tokyo Cabinet
http://fallabs.com/tokyocabinet/

Tokyo Dystopia
http://fallabs.com/tokyodystopia/

BNRPersistence
https://github.com/hillegass/BNRPersistence
iPhone SDK
Tokyo Cabinet
DBM



Tokyo Dystopia
Tokyo Cabinet


FTSKit
BNRPersistence
Tokyo Dystopia   Cocoa Wrapper
iPhone SDK


             Sample Code


FTSKit
https://github.com/kishikawakatsumi/FTSKit
iPhone SDK



   FKStoredObject
iPhone SDK
#import "FKStoredObject.h"

@interface Address : FKStoredObject {
  NSString *zipcode;
  NSString *full;
  NSString *kana;
}

@property (nonatomic, retain) NSString *zipcode;
@property (nonatomic, retain) NSString *full;
@property (nonatomic, retain) NSString *kana;

@end
iPhone SDK
#import "FKStoredObject.h"

@interface Address : FKStoredObject {
  NSString *zipcode;
  NSString *full;
  NSString *kana;
}

@property (nonatomic, retain) NSString *zipcode;
@property (nonatomic, retain) NSString *full;
@property (nonatomic, retain) NSString *kana;

@end
@implementation Address
              iPhone SDK
- (void)readContentFromBuffer:(FKDataBuffer *)d {
   [zipcode release];
   zipcode = [[d readString] retain];

    [full release];
    full = [[d readString] retain];

    [kana release];
    kana = [[d readString] retain];
}

- (void)writeContentToBuffer:(FKDataBuffer *)d {
   [d writeString:zipcode];
   [d writeString:full];
   [d writeString:kana];
}

@end
iPhone SDK



       Save
iPhone SDK

      FKStore


   FKStoreBackend


  FKIndexManager
iPhone SDK
self.store = [[[FKStore alloc] init] autorelease];

FKTCBackend *backend =
 [[FKTCBackend alloc] initWithPath:dataPath
                   error:nil];
[store setBackend:backend];
[backend release];

FKTCIndexManager *indexManager =
 [[FKTCIndexManager alloc] initWithPath:dataPath
                     error:nil];
[store setIndexManager:indexManager];
[indexManager release];

[store addClass:[Address class]];
iPhone SDK
// Mark object for insertion into object store
- (void)insertObject:(FKStoredObject *)obj;

// Mark object for deletion from object store
- (void)deleteObject:(FKStoredObject *)obj;

// Mark object to be updated in object store
- (void)willUpdateObject:(FKStoredObject *)obj;

- (BOOL)saveChanges:(NSError **)errorPtr;
iPhone SDK
CSVParser *parser = [[[CSVParser alloc]
               initWithString:csvString
                   separator:@","
                   hasHeader:YES
                  fieldNames:nil] autorelease];
NSArray *lines = [parser arrayOfParsedRows];
for (NSDictionary *line in lines) {
   Address *record = [[Address alloc] init];
   record.zipcode = [line objectForKey:@"               "];
    record.full = [line objectForKey:@"   "];
    record.kana = [line objectForKey:@"           "];

    [store insertObject:record];
    [record release];
}

[store saveChanges:nil];
iPhone SDK



      Search
iPhone SDK
- (FKResultSet *)resultSetForClass:(Class)c
              mactchesText:(NSString *)text
                   forKey:(NSString *)key;

- (FKResultSet *)resultSetForClass:(Class)c
              containsText:(NSString *)text
                   forKey:(NSString *)key;

- (FKResultSet *)resultSetForClass:(Class)c
             beginsWithText:(NSString *)text
                   forKey:(NSString *)key;

- (FKResultSet *)resultSetForClass:(Class)c
              endsWithText:(NSString *)text
                   forKey:(NSString *)key;
NSString *text = searchText;

             iPhone SDK
NSString *key = @"kana";

FKResultSet *resultSet;
if (searchType == FKSearchTypeStartsWith) {
    resultSet = [store resultSetForClass:[Address class]
                   beginsWithText:text
                         forKey:key];
} else if (searchType == FKSearchTypeEndsWith) {
    resultSet = [store resultSetForClass:[Address class]
                    endsWithText:text
                         forKey:key];
} else if (searchType == FKSearchTypeContains) {
    resultSet = [store resultSetForClass:[Address class]
                    containsText:text
                         forKey:key];
} else {
    resultSet = [store resultSetForClass:[Address class]
                    mactchesText:text
                         forKey:key];
}
iPhone SDK


Performance Tuning
iPhone SDK

    Performance Tuning


•
•       2:8
•
iPhone SDK
iPhone SDK




•
iPhone SDK
iPhone SDK
iPhone SDK




             OK.
iPhone SDK
iPhone SDK
       •
       •
       •
       iPhone
iPhone SDK




•



•
iPhone SDK

- (void)searchBar:(FKSearchBar *)searchBar
   textDidChange:(NSString *)searchText {
   [NSObject
    cancelPreviousPerformRequestsWithTarget:self];
   [self performSelector:@selector(searchWithSearchBar:)
           withObject:searchBar
           afterDelay:0.2];
}
- (void)searchWithSearchBar:(FKSearchBar *)searchBar {

               iPhone SDK
   [queue cancelAllOperations];

    NSString *searchText = searchBar.text;
    if ([searchText length] == 0) {
        self.resultSet = nil;
        [listView reloadData];
        return;
    }

    FKSearchOperation *searchOperation =
     [[FKSearchOperation alloc] init];
    searchOperation.delegate = self;
    searchOperation.store = store;
    searchOperation.searchText = searchText;
    searchOperation.searchType = searchBar.searchType;

    [queue addOperation:searchOperation];
    [searchOperation release];
}

- (void)searchOperaionDidFinished:(FKResultSet *)results {
   self.resultSet = results;
   [listView reloadData];
}
iPhone SDK


        API Cocoa


Foundation
iPhone SDK
iPhone SDK


Boolean CFStringTransform (
   CFMutableStringRef string,
   CFRange *range,
   CFStringRef transform,
   Boolean reverse
);
iPhone SDK
const   CFStringRef   kCFStringTransformStripCombiningMarks;
const   CFStringRef   kCFStringTransformToLatin;
const   CFStringRef   kCFStringTransformFullwidthHalfwidth;
const   CFStringRef   kCFStringTransformLatinKatakana;
const   CFStringRef   kCFStringTransformLatinHiragana;
const   CFStringRef   kCFStringTransformHiraganaKatakana;
const   CFStringRef   kCFStringTransformMandarinLatin;
const   CFStringRef   kCFStringTransformLatinHangul;
const   CFStringRef   kCFStringTransformLatinArabic;
const   CFStringRef   kCFStringTransformLatinHebrew;
const   CFStringRef   kCFStringTransformLatinThai;
const   CFStringRef   kCFStringTransformLatinCyrillic;
const   CFStringRef   kCFStringTransformLatinGreek;
const   CFStringRef   kCFStringTransformToXMLHex;
const   CFStringRef   kCFStringTransformToUnicodeName;
const   CFStringRef   kCFStringTransformStripDiacritics;
iPhone SDK
NSString *text = searchText;

NSMutableString *toKana =
 [NSMutableString stringWithString:text];
CFRange range = CFRangeMake(0, [text length]);
CFStringTransform((CFMutableStringRef)toKana,
            &range,
            kCFStringTransformHiraganaKatakana,
            false);
text = toKana;



 CF~    NS~                        (toll-free bridge)
                                            Cocoa
 ※UI~
iPhone SDK
iPhone SDK


CFIndex CFArrayBSearchValues (
   CFArrayRef theArray,
   CFRange range,
   const void *value,
   CFComparatorFunction comparator,
   void *context
);
NSArray *sortedArray;
           iPhone SDK
NSNumber *target = [NSNumber numberWithInteger:10];
CFIndex count = [sortedArray count];
CFRange range = CFRangeMake(0, count);
AData *data = nil;

CFIndex index = CFArrayBSearchValues(
                         (CFArrayRef)sortedArray,
                         range,
                         target,
                         compareAData,
                         NULL);
if(index < count) {
    data = [sortedArray objetAtIndex:index];
} else {
    // Not found.
}
if(NSOrderedSame != [data.number compare:target]) {
    // Not found.
}
NSBinarySearchingOptions
                 iPhone SDK
Options for searches and insertions using
indexOfObject:inSortedRange:options:usingComparator:.
enum {
   NSBinarySearchingFirstEqual = (1 << 8),
   NSBinarySearchingLastEqual = (1 << 9),
   NSBinarySearchingInsertionIndex = (1 << 10),
};
typedef NSUInteger NSBinarySearchingOptions;
Constants
NSBinarySearchingFirstEqual
Specifies that the search should return the first object in the range that is equal to the given object.
Available in iOS 4.0 and later.
Declared in NSArray.h.
NSBinarySearchingLastEqual
Specifies that the search should return the last object in the range that is equal to the given object.
Available in iOS 4.0 and later.
Declared in NSArray.h.
NSBinarySearchingInsertionIndex
Returns the index at which you should insert the object in order to maintain a sorted array.
Available in iOS 4.0 and later.
Declared in NSArray.h.
iPhone SDK
iPhone SDK


 NSString
CFURL
iPhone SDK


- (NSString *)stringByAddingPercentEscapesUsingEncoding:
(NSStringEncoding)encoding


- (NSString
*)stringByReplacingPercentEscapesUsingEncoding:
(NSStringEncoding)encoding
iPhone SDK
CFStringRef CFURLCreateStringByReplacingPercentEscapes (
   CFAllocatorRef allocator,
   CFStringRef originalString,
   CFStringRef charactersToLeaveEscaped
);


CFStringRef
CFURLCreateStringByReplacingPercentEscapesUsingEncodin
g(
   CFAllocatorRef allocator,
   CFStringRef origString,
   CFStringRef charsToLeaveEscaped,
   CFStringEncoding encoding
);

Weitere ähnliche Inhalte

Kürzlich hochgeladen

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Kürzlich hochgeladen (20)

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
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
 
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
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - 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
 

Empfohlen

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Empfohlen (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

iPhone勉強会 (2011.04.30) 全文検索 -Full Text Search on iOS-

  • 3. iPhone SDK • 
touch • 
on
the
WEB •LDR
touch • • •i‐Radio •LCD
Clock • •Subway
Map • •MyWebClip • •
  • 4. iPhone SDK http://github.com/kishikawakatsumi •hatena‐touch •DescripMonBuilder •ldr‐touch •TiledLayerView •tv‐lisMngs •UICCalendarPicker •MapKit‐Route‐DirecMons •FlipCardNavigaMonView •PhotoFlipCardView
  • 8. iPhone SDK (SQLite? CoreData? and so on...) • •
  • 9. iPhone SDK Library Tokyo Cabinet http://fallabs.com/tokyocabinet/ Tokyo Dystopia http://fallabs.com/tokyodystopia/ BNRPersistence https://github.com/hillegass/BNRPersistence
  • 10. iPhone SDK Tokyo Cabinet DBM Tokyo Dystopia Tokyo Cabinet FTSKit BNRPersistence Tokyo Dystopia Cocoa Wrapper
  • 11. iPhone SDK Sample Code FTSKit https://github.com/kishikawakatsumi/FTSKit
  • 12. iPhone SDK FKStoredObject
  • 13. iPhone SDK #import "FKStoredObject.h" @interface Address : FKStoredObject { NSString *zipcode; NSString *full; NSString *kana; } @property (nonatomic, retain) NSString *zipcode; @property (nonatomic, retain) NSString *full; @property (nonatomic, retain) NSString *kana; @end
  • 14. iPhone SDK #import "FKStoredObject.h" @interface Address : FKStoredObject { NSString *zipcode; NSString *full; NSString *kana; } @property (nonatomic, retain) NSString *zipcode; @property (nonatomic, retain) NSString *full; @property (nonatomic, retain) NSString *kana; @end
  • 15. @implementation Address iPhone SDK - (void)readContentFromBuffer:(FKDataBuffer *)d { [zipcode release]; zipcode = [[d readString] retain]; [full release]; full = [[d readString] retain]; [kana release]; kana = [[d readString] retain]; } - (void)writeContentToBuffer:(FKDataBuffer *)d { [d writeString:zipcode]; [d writeString:full]; [d writeString:kana]; } @end
  • 16. iPhone SDK Save
  • 17. iPhone SDK FKStore FKStoreBackend FKIndexManager
  • 18. iPhone SDK self.store = [[[FKStore alloc] init] autorelease]; FKTCBackend *backend = [[FKTCBackend alloc] initWithPath:dataPath error:nil]; [store setBackend:backend]; [backend release]; FKTCIndexManager *indexManager = [[FKTCIndexManager alloc] initWithPath:dataPath error:nil]; [store setIndexManager:indexManager]; [indexManager release]; [store addClass:[Address class]];
  • 19. iPhone SDK // Mark object for insertion into object store - (void)insertObject:(FKStoredObject *)obj; // Mark object for deletion from object store - (void)deleteObject:(FKStoredObject *)obj; // Mark object to be updated in object store - (void)willUpdateObject:(FKStoredObject *)obj; - (BOOL)saveChanges:(NSError **)errorPtr;
  • 20. iPhone SDK CSVParser *parser = [[[CSVParser alloc] initWithString:csvString separator:@"," hasHeader:YES fieldNames:nil] autorelease]; NSArray *lines = [parser arrayOfParsedRows]; for (NSDictionary *line in lines) { Address *record = [[Address alloc] init]; record.zipcode = [line objectForKey:@" "]; record.full = [line objectForKey:@" "]; record.kana = [line objectForKey:@" "]; [store insertObject:record]; [record release]; } [store saveChanges:nil];
  • 21. iPhone SDK Search
  • 22. iPhone SDK - (FKResultSet *)resultSetForClass:(Class)c mactchesText:(NSString *)text forKey:(NSString *)key; - (FKResultSet *)resultSetForClass:(Class)c containsText:(NSString *)text forKey:(NSString *)key; - (FKResultSet *)resultSetForClass:(Class)c beginsWithText:(NSString *)text forKey:(NSString *)key; - (FKResultSet *)resultSetForClass:(Class)c endsWithText:(NSString *)text forKey:(NSString *)key;
  • 23. NSString *text = searchText; iPhone SDK NSString *key = @"kana"; FKResultSet *resultSet; if (searchType == FKSearchTypeStartsWith) { resultSet = [store resultSetForClass:[Address class] beginsWithText:text forKey:key]; } else if (searchType == FKSearchTypeEndsWith) { resultSet = [store resultSetForClass:[Address class] endsWithText:text forKey:key]; } else if (searchType == FKSearchTypeContains) { resultSet = [store resultSetForClass:[Address class] containsText:text forKey:key]; } else { resultSet = [store resultSetForClass:[Address class] mactchesText:text forKey:key]; }
  • 25. iPhone SDK Performance Tuning • • 2:8 •
  • 30. iPhone SDK OK.
  • 32. iPhone SDK • • • iPhone
  • 34. iPhone SDK - (void)searchBar:(FKSearchBar *)searchBar textDidChange:(NSString *)searchText { [NSObject cancelPreviousPerformRequestsWithTarget:self]; [self performSelector:@selector(searchWithSearchBar:) withObject:searchBar afterDelay:0.2]; }
  • 35. - (void)searchWithSearchBar:(FKSearchBar *)searchBar { iPhone SDK [queue cancelAllOperations]; NSString *searchText = searchBar.text; if ([searchText length] == 0) { self.resultSet = nil; [listView reloadData]; return; } FKSearchOperation *searchOperation = [[FKSearchOperation alloc] init]; searchOperation.delegate = self; searchOperation.store = store; searchOperation.searchText = searchText; searchOperation.searchType = searchBar.searchType; [queue addOperation:searchOperation]; [searchOperation release]; } - (void)searchOperaionDidFinished:(FKResultSet *)results { self.resultSet = results; [listView reloadData]; }
  • 36. iPhone SDK API Cocoa Foundation
  • 38. iPhone SDK Boolean CFStringTransform ( CFMutableStringRef string, CFRange *range, CFStringRef transform, Boolean reverse );
  • 39. iPhone SDK const CFStringRef kCFStringTransformStripCombiningMarks; const CFStringRef kCFStringTransformToLatin; const CFStringRef kCFStringTransformFullwidthHalfwidth; const CFStringRef kCFStringTransformLatinKatakana; const CFStringRef kCFStringTransformLatinHiragana; const CFStringRef kCFStringTransformHiraganaKatakana; const CFStringRef kCFStringTransformMandarinLatin; const CFStringRef kCFStringTransformLatinHangul; const CFStringRef kCFStringTransformLatinArabic; const CFStringRef kCFStringTransformLatinHebrew; const CFStringRef kCFStringTransformLatinThai; const CFStringRef kCFStringTransformLatinCyrillic; const CFStringRef kCFStringTransformLatinGreek; const CFStringRef kCFStringTransformToXMLHex; const CFStringRef kCFStringTransformToUnicodeName; const CFStringRef kCFStringTransformStripDiacritics;
  • 40. iPhone SDK NSString *text = searchText; NSMutableString *toKana = [NSMutableString stringWithString:text]; CFRange range = CFRangeMake(0, [text length]); CFStringTransform((CFMutableStringRef)toKana, &range, kCFStringTransformHiraganaKatakana, false); text = toKana; CF~ NS~ (toll-free bridge) Cocoa ※UI~
  • 42. iPhone SDK CFIndex CFArrayBSearchValues ( CFArrayRef theArray, CFRange range, const void *value, CFComparatorFunction comparator, void *context );
  • 43. NSArray *sortedArray; iPhone SDK NSNumber *target = [NSNumber numberWithInteger:10]; CFIndex count = [sortedArray count]; CFRange range = CFRangeMake(0, count); AData *data = nil; CFIndex index = CFArrayBSearchValues( (CFArrayRef)sortedArray, range, target, compareAData, NULL); if(index < count) { data = [sortedArray objetAtIndex:index]; } else { // Not found. } if(NSOrderedSame != [data.number compare:target]) { // Not found. }
  • 44. NSBinarySearchingOptions iPhone SDK Options for searches and insertions using indexOfObject:inSortedRange:options:usingComparator:. enum { NSBinarySearchingFirstEqual = (1 << 8), NSBinarySearchingLastEqual = (1 << 9), NSBinarySearchingInsertionIndex = (1 << 10), }; typedef NSUInteger NSBinarySearchingOptions; Constants NSBinarySearchingFirstEqual Specifies that the search should return the first object in the range that is equal to the given object. Available in iOS 4.0 and later. Declared in NSArray.h. NSBinarySearchingLastEqual Specifies that the search should return the last object in the range that is equal to the given object. Available in iOS 4.0 and later. Declared in NSArray.h. NSBinarySearchingInsertionIndex Returns the index at which you should insert the object in order to maintain a sorted array. Available in iOS 4.0 and later. Declared in NSArray.h.
  • 47. iPhone SDK - (NSString *)stringByAddingPercentEscapesUsingEncoding: (NSStringEncoding)encoding - (NSString *)stringByReplacingPercentEscapesUsingEncoding: (NSStringEncoding)encoding
  • 48. iPhone SDK CFStringRef CFURLCreateStringByReplacingPercentEscapes ( CFAllocatorRef allocator, CFStringRef originalString, CFStringRef charactersToLeaveEscaped ); CFStringRef CFURLCreateStringByReplacingPercentEscapesUsingEncodin g( CFAllocatorRef allocator, CFStringRef origString, CFStringRef charsToLeaveEscaped, CFStringEncoding encoding );

Hinweis der Redaktion

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n