Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-23528] iOS10: Expose new CoreSpotlight API's #8070

Merged
merged 4 commits into from
Jul 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 21 additions & 0 deletions apidoc/Titanium/App/iOS/SearchableItemAttributeSet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,27 @@ properties:
summary: URL of the item.
type: String
osver: {ios: {min: "9.0"}}
- name: fullyFormattedAddress
summary: The fully formatted address of the item (obtained from MapKit).
type: String
osver: {ios: {min: "10.0"}}
since: "6.0.0"
- name: subThoroughfare
summary: The sub-location (e.g., street number) for the item according to guidelines established by the provider.
type: String
osver: {ios: {min: "10.0"}}
since: "6.0.0"
- name: thoroughfare
summary: The location (e.g., street name) for the item according to guidelines established by the provider.
type: String
osver: {ios: {min: "10.0"}}
since: "6.0.0"
- name: postalCode
summary: The postal code for the item according to guidelines established by the provider.
type: String
osver: {ios: {min: "10.0"}}
since: "6.0.0"

platforms: [iphone,ipad]
examples:
- title: Add Searchable Content to the On-Device Index
Expand Down
65 changes: 61 additions & 4 deletions iphone/Classes/TiAppiOSSearchableItemAttributeSetProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ -(void)applyLoadTimeProperties:(NSDictionary*)props
}
}
else{
NSLog(@"[ERROR] field %@ is invalid",key);
NSLog(@"[ERROR] The property \"%@\" is invalid. Please check the property-name and iOS-compatibility.",key);
}
}];
}
Expand Down Expand Up @@ -319,14 +319,14 @@ -(void)setFileSize:(id)value
//Number of pages in the item.
-(NSNumber*)pageCount
{
return _attributes.pageHeight;
return _attributes.pageCount;
}

-(void)setPageCount:(id)value
{
ENSURE_SINGLE_ARG(value,NSNumber);
ENSURE_UI_THREAD(setPageCount,value);
_attributes.pageHeight = value;
_attributes.pageCount = value;
}

//Width in points (72 points per inch) of the document page
Expand Down Expand Up @@ -1317,5 +1317,62 @@ -(void)setUrl:(id)value
_attributes.URL = [self sanitizeURL:value];;
}

#if IS_XCODE_8

// The fully formatted address of the item (obtained from MapKit)
-(NSString*)fullyFormattedAddress
{
return [_attributes fullyFormattedAddress];
}

-(void)setFullyFormattedAddress:(id)value
{
ENSURE_SINGLE_ARG(value, NSString);
ENSURE_UI_THREAD(setFullyFormattedAddress, value);
[_attributes setFullyFormattedAddress:[TiUtils stringValue:value]];
}

// The postal code for the item according to guidelines established by the provider.
-(NSString*)postalCode
{
return [_attributes postalCode];
}

-(void)setPostalCode:(id)value
{
ENSURE_IOS_API(@"10", @"Ti.App.iOS.SearchableItemAttributSet.postalCode");
ENSURE_SINGLE_ARG(value, NSString);
ENSURE_UI_THREAD(setPostalCode, value);
[_attributes setPostalCode:[TiUtils stringValue:value]];
}

// The sub-location (e.g., street number) for the item according to guidelines established by the provider.
-(NSString*)subThoroughfare
{
return [_attributes subThoroughfare];
}

-(void)setSubThoroughfare:(id)value
{
ENSURE_SINGLE_ARG(value, NSString);
ENSURE_UI_THREAD(setSubThoroughfare, value);
[_attributes setSubThoroughfare:[TiUtils stringValue:value]];
}

// The location (e.g., street name) for the item according to guidelines established by the provider.
-(NSString*)thoroughfare
{
return [_attributes thoroughfare];
}

-(void)setThoroughfare:(id)value
{
ENSURE_SINGLE_ARG(value, NSString);
ENSURE_UI_THREAD(setThoroughfare, value);
[_attributes setThoroughfare:[TiUtils stringValue:value]];
}

#endif

@end
#endif
#endif
6 changes: 6 additions & 0 deletions iphone/Classes/TiThreading.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ if (![NSThread isMainThread]) { \
return; \
} \

#define ENSURE_IOS_API(version, message) \
if ([[[UIDevice currentDevice] systemVersion] compare:version options:NSNumericSearch] != NSOrderedAscending) { \
NSLog(@"[WARN] %@ is only available on iOS %@ and later.", message, version); \
return; \
} \

//TODO: Now that we have TiThreadPerform, we should optimize this out.
#define ENSURE_UI_THREAD_WITH_OBJ(x,y,z) \
if (![NSThread isMainThread]) { \
Expand Down