SlideShare une entreprise Scribd logo
1  sur  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
);

Contenu connexe

Dernier

Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
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
 
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
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
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
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 

Dernier (20)

Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
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
 
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
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.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
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 

En vedette

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 HubspotMarius Sescu
 
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 ChatGPTExpeed Software
 
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 EngineeringsPixeldarts
 
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 HealthThinkNow
 
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.pdfmarketingartwork
 
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 2024Neil Kimberley
 
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)contently
 
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 2024Albert Qian
 
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 InsightsKurio // The Social Media Age(ncy)
 
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 2024Search Engine Journal
 
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 summarySpeakerHub
 
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 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 Tessa Mero
 
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 IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
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 managementMindGenius
 
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...RachelPearson36
 

En vedette (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 );

Notes de l'éditeur

  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