草庐IT

ios - 加载对象 x-apple-eventkit 的默认属性时出错

coder 2023-09-30 原文

帮助在 Icloud 日历中创建和保存事件。保存后出现错误:

Error loading default properties for object x-apple-eventkit:///Alarm/p252 from daemon: Error Domain=EKCADErrorDomain Code=1010 "(null)"



Error loading to-one relation originalAlarm from daemon: Error Domain=EKCADErrorDomain Code=1010 "(null)"

我的代码:

    NSDateFormatter *dateFromater = [[NSDateFormatter alloc]init];
NSTimeZone * timeZone = [NSTimeZone localTimeZone];
[dateFromater setTimeZone:timeZone];
[dateFromater setDateFormat:@"Y-MM-d'T'HH:mm:ss'.000Z'"];
EKEventStore* evStore = [[EKEventStore alloc]init];
[evStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError * _Nullable error) {

    EKEvent * event = [EKEvent eventWithEventStore:evStore];


    event.location=[dictionry valueForKey:@"location"];
    event.title = [dictionry valueForKey:@"eventName"];
    event.notes = [dictionry valueForKey:@"description"];

    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"];
    NSString *str = [formatter stringFromDate:[NSDate date]];


    event.startDate = [formatter dateFromString:[dictionry valueForKey:@"eventDate"]]; //[dictionry valueForKey:@"eventDate"];
    event.endDate = [event.startDate dateByAddingTimeInterval:60];

    EKAlarm *ekAlarm = [EKAlarm alarmWithRelativeOffset:-60];
    [event addAlarm:ekAlarm];

    RLMResults *object = [RealmUser allObjects];
    self.user= [object firstObject];
    event.calendar = [evStore calendarWithIdentifier:self.user.calendarIdentifier];

    EKRecurrenceEnd * end = [EKRecurrenceEnd recurrenceEndWithEndDate:[NSDate dateWithTimeIntervalSince1970:[[dictionry objectForKey:@"endDateForReps"]intValue]]];
    EKRecurrenceFrequency  freq;
    NSString    *timeUntilForReps =[dictionry objectForKey:@"timeUnitForReps"] ;

    if ([timeUntilForReps isEqualToString:@"week"]) freq = EKRecurrenceFrequencyWeekly;
    else if ([timeUntilForReps isEqualToString:@"day"]) freq = EKRecurrenceFrequencyDaily;
    else if ([timeUntilForReps isEqualToString:@"year"]) freq = EKRecurrenceFrequencyYearly;
    else if ([timeUntilForReps isEqualToString:@"mounth"]) freq = EKRecurrenceFrequencyMonthly;

    NSInteger timeInterval = [[dictionry valueForKey:@"repeatInterval"] integerValue];
    EKRecurrenceRule * rule = [[EKRecurrenceRule alloc]initRecurrenceWithFrequency:freq interval:timeInterval end:end];
    [event setRecurrenceRules:@[rule]];


    [evStore saveEvent:event span:EKSpanThisEvent commit:YES error:&error];
    if (error) NSLog(@"error");

}];

最佳答案

我在阅读日历事件时遇到了这组错误:

Error loading default properties for object x-apple-eventkit:///Location/p1 from daemon: Error Domain=EKCADErrorDomain Code=1013 "(null)"
Error loading string title from daemon: Error Domain=EKCADErrorDomain Code=1013 "(null)"
Error loading default properties for object x-apple-eventkit:///Location/p1 from daemon: Error Domain=EKCADErrorDomain Code=1013 "(null)"
Error loading string address from daemon: Error Domain=EKCADErrorDomain Code=1013 "(null)"

使用 NSLog,我确定消息是在处理一个特定事件时发生的。

根据消息,我想记录事件的位置值并将其与其他返回的事件进行比较。不过,该值似乎只是一个空字符串,所有其他事件也都是空字符串。

进一步检查实际日历,我发现这个特定事件在其位置字段中有一个空格或一些不可见的字符(显示删除 x,但似乎没有字符在场)。我通过按 x 删除了不可见字符:没有更多消息!

在这种情况下,不是我的代码导致了问题。但是,错误消息的提示使我找到了解决方案。如果我一直在构建事件,我会查看有关创建 Location 属性数据的代码。

总结:

  • 注意与错误相关的属性。

  • 注意属性错误后的附加错误消息。

  • 将故障排除重点放在该区域。

关于ios - 加载对象 x-apple-eventkit 的默认属性时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39364467/

有关ios - 加载对象 x-apple-eventkit 的默认属性时出错的更多相关文章

  1. ruby - 如何从 ruby​​ 中的字符串运行任意对象方法? - 2

    总的来说,我对ruby​​还比较陌生,我正在为我正在创建的对象编写一些rspec测试用例。许多测试用例都非常基础,我只是想确保正确填充和返回值。我想知道是否有办法使用循环结构来执行此操作。不必为我要测试的每个方法都设置一个assertEquals。例如:describeitem,"TestingtheItem"doit"willhaveanullvaluetostart"doitem=Item.new#HereIcoulddotheitem.name.shouldbe_nil#thenIcoulddoitem.category.shouldbe_nilendend但我想要一些方法来使用

  2. ruby-on-rails - 按天对 Mongoid 对象进行分组 - 2

    在控制台中反复尝试之后,我想到了这种方法,可以按发生日期对类似activerecord的(Mongoid)对象进行分组。我不确定这是完成此任务的最佳方法,但它确实有效。有没有人有更好的建议,或者这是一个很好的方法?#eventsisanarrayofactiverecord-likeobjectsthatincludeatimeattributeevents.map{|event|#converteventsarrayintoanarrayofhasheswiththedayofthemonthandtheevent{:number=>event.time.day,:event=>ev

  3. ruby - ECONNRESET (Whois::ConnectionError) - 尝试在 Ruby 中查询 Whois 时出错 - 2

    我正在用Ruby编写一个简单的程序来检查域列表是否被占用。基本上它循环遍历列表,并使用以下函数进行检查。require'rubygems'require'whois'defcheck_domain(domain)c=Whois::Client.newc.query("google.com").available?end程序不断出错(即使我在google.com中进行硬编码),并打印以下消息。鉴于该程序非常简单,我已经没有什么想法了-有什么建议吗?/Library/Ruby/Gems/1.8/gems/whois-2.0.2/lib/whois/server/adapters/base.

  4. ruby - 在 64 位 Snow Leopard 上使用 rvm、postgres 9.0、ruby 1.9.2-p136 安装 pg gem 时出现问题 - 2

    我想为Heroku构建一个Rails3应用程序。他们使用Postgres作为他们的数据库,所以我通过MacPorts安装了postgres9.0。现在我需要一个postgresgem并且共识是出于性能原因你想要pggem。但是我对我得到的错误感到非常困惑当我尝试在rvm下通过geminstall安装pg时。我已经非常明确地指定了所有postgres目录的位置可以找到但仍然无法完成安装:$envARCHFLAGS='-archx86_64'geminstallpg--\--with-pg-config=/opt/local/var/db/postgresql90/defaultdb/po

  5. ruby-on-rails - 如果为空或不验证数值,则使属性默认为 0 - 2

    我希望我的UserPrice模型的属性在它们为空或不验证数值时默认为0。这些属性是tax_rate、shipping_cost和price。classCreateUserPrices8,:scale=>2t.decimal:tax_rate,:precision=>8,:scale=>2t.decimal:shipping_cost,:precision=>8,:scale=>2endendend起初,我将所有3列的:default=>0放在表格中,但我不想要这样,因为它已经填充了字段,我想使用占位符。这是我的UserPrice模型:classUserPrice回答before_val

  6. ruby-on-rails - 在混合/模块中覆盖模型的属性访问器 - 2

    我有一个包含模块的模型。我想在模块中覆盖模型的访问器方法。例如:classBlah这显然行不通。有什么想法可以实现吗? 最佳答案 您的代码看起来是正确的。我们正在毫无困难地使用这个确切的模式。如果我没记错的话,Rails使用#method_missing作为属性setter,因此您的模块将优先,阻止ActiveRecord的setter。如果您正在使用ActiveSupport::Concern(参见thisblogpost),那么您的实例方法需要进入一个特殊的模块:classBlah

  7. ruby - 默认情况下使选项为 false - 2

    这是在Ruby中设置默认值的常用方法:classQuietByDefaultdefinitialize(opts={})@verbose=opts[:verbose]endend这是一个容易落入的陷阱:classVerboseNoMatterWhatdefinitialize(opts={})@verbose=opts[:verbose]||trueendend正确的做法是:classVerboseByDefaultdefinitialize(opts={})@verbose=opts.include?(:verbose)?opts[:verbose]:trueendend编写Verb

  8. ruby - 如何在续集中重新加载表模式? - 2

    鉴于我有以下迁移:Sequel.migrationdoupdoalter_table:usersdoadd_column:is_admin,:default=>falseend#SequelrunsaDESCRIBEtablestatement,whenthemodelisloaded.#Atthispoint,itdoesnotknowthatusershaveais_adminflag.#Soitfails.@user=User.find(:email=>"admin@fancy-startup.example")@user.is_admin=true@user.save!ende

  9. ruby-on-rails - 如何验证非模型(甚至非对象)字段 - 2

    我有一个表单,其中有很多字段取自数组(而不是模型或对象)。我如何验证这些字段的存在?solve_problem_pathdo|f|%>... 最佳答案 创建一个简单的类来包装请求参数并使用ActiveModel::Validations。#definedsomewhere,atthesimplest:require'ostruct'classSolvetrue#youcouldevencheckthesolutionwithavalidatorvalidatedoerrors.add(:base,"WRONG!!!")unlesss

  10. Ruby 写入和读取对象到文件 - 2

    好的,所以我的目标是轻松地将一些数据保存到磁盘以备后用。您如何简单地写入然后读取一个对象?所以如果我有一个简单的类classCattr_accessor:a,:bdefinitialize(a,b)@a,@b=a,bendend所以如果我从中非常快地制作一个objobj=C.new("foo","bar")#justgaveitsomerandomvalues然后我可以把它变成一个kindaidstring=obj.to_s#whichreturns""我终于可以将此字符串打印到文件或其他内容中。我的问题是,我该如何再次将这个id变回一个对象?我知道我可以自己挑选信息并制作一个接受该信

随机推荐