我正在使用Apple提供的API从AddressBook中读取记录.
我仍在考虑内存管理,所以CFStrings此刻让我感到困惑.
这就是我获取属性的方式:
//Get Basic properties
NSString* firstName = (NSString *)ABRecordCopyValue(person, kABPersonFirstNameProperty);
NSString* lastName = (NSString *)ABRecordCopyValue(person, kABPersonLastNameProperty);
NSNumber* record = [NSNumber numberWithInt:ABRecordGetRecordID(person)];
//Build Full Name
NSString* fullName=[self fullNameWith:firstName and:lastName];
//Get Phone number and Label
ABMultiValueRef phone = ABRecordCopyValue(person, property);
//Turn identifier into index
CFIndex index = ABMultiValueGetIndexForIdentifier(phone, identifier);
//Get the value and the label using the index
NSString *value =(NSString *)ABMultiValueCopyValueAtIndex(phone, index);
CFStringRef label = ABMultiValueCopyLabelAtIndex(phone, index);
//Get the localized value of hte label
NSString * localizedLabel …Run Code Online (Sandbox Code Playgroud) 我在使用动作表选择器视图.它工作正常.但是我想local notification在特定的时间开始时time picker发射,它不会发射local notification.我用过这段代码:
enter code here
- (void)actionPickerDone {
if (nil != self.data) {
//send data picker message[self.target performSelector:self.action withObject:[NSNumbernumberWithInt:self.selectedIndex]];
}
else {
//send date picker message
NSCalendar *calendar = [NSCalendar autoupdatingCurrentCalendar];
// Get the current date
NSDate *pickerDate = [self.datePicker date];
// Break the date up into components
NSDateComponents *dateComponents = [calendar components:( NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit )
fromDate:pickerDate];
NSDateComponents *timeComponents = [calendar components:( NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit )
fromDate:pickerDate]; …Run Code Online (Sandbox Code Playgroud) 我有一个NSString&我想从中删除一些字符,当它中找到第一个逗号时.
ex. str = @"0,1,2,3";
output - > str = @"1,2,3";
Run Code Online (Sandbox Code Playgroud)
这该怎么做.任何人都可以帮我解决这个问题.
我的秒数为54000.我如何得到时间为下午3:00点?
我可以使用任何dateformatter来获取它吗?
谢谢