jjzjj

ios - 创建地理围栏时 NSCFNumber getCString maxLength 编码错误

coder 2024-01-19 原文

当我尝试将半径添加到防护应用程序时,我遇到了 [__NSCFNumber getCString:maxLength:encoding:] 崩溃。 这是我的代码:

NSString *identifier = [dictionary valueForKey:@"id"];

CLLocationDegrees latitude = [[dictionary valueForKey:@"lat"] doubleValue];

CLLocationDegrees longitude =[[dictionary valueForKey:@"lon"] doubleValue];

CLLocationCoordinate2D centerCoordinate = CLLocationCoordinate2DMake(latitude, longitude);

CLLocationDistance regionRadius = [[dictionary valueForKey:@"radius"] doubleValue];
NSLog(@"nslog is %f",regionRadius);


if(regionRadius > _locationManager.maximumRegionMonitoringDistance)
{
    regionRadius = _locationManager.maximumRegionMonitoringDistance;
}

NSString *version = [[UIDevice currentDevice] systemVersion];
CLRegion * region =nil;

if([version floatValue] >= 7.0f) // for iOS > 7
{
    region =  [[CLCircularRegion alloc] initWithCenter:centerCoordinate
                                                radius:regionRadius
                                            identifier:identifier];
}
else // for iOS < 7
{
    region = [[CLRegion alloc] initCircularRegionWithCenter:centerCoordinate
                                                     radius:regionRadius
                                                 identifier:identifier];
}

Stacktrace 在这里

0   KNOXXi                              0x00064c8b -[KCSDK dictToRegion:] + 854
1   KNOXXi                              0x000640cf -[KCSDK addGeofence:] + 86
2   KNOXXi                              0x00065d25 __25-[KCSDK reloadLocations:]_block_invoke + 536
3   KNOXXi                              0x0006369d __59-[KCSDK fetchNearbyFencesWithLocation:withSuccess:failure:]_block_invoke + 196
4   KNOXXi                              0x0002762d __64-[AFHTTPRequestOperation setCompletionBlockWithSuccess:failure:]_block_invoke46 + 36
5   libdispatch.dylib                   0x3992f833 <redacted> + 10
6   libdispatch.dylib                   0x3992f81f <redacted> + 22
7   libdispatch.dylib                   0x3993649f <redacted> + 278
8   CoreFoundation                      0x2e7648a1 <redacted> + 8
9   CoreFoundation                      0x2e763175 <redacted> + 1300
10  CoreFoundation                      0x2e6cdebf CFRunLoopRunSpecific + 522
11  CoreFoundation                      0x2e6cdca3 CFRunLoopRunInMode + 106
12  GraphicsServices                    0x33601663 GSEventRunModal + 138
13  UIKit                               0x3101a14d UIApplicationMain + 1136
14  KNOXXi                              0x00026411 main + 224
15  libdyld.dylib                       0x39954ab7 <redacted> + 2

最佳答案

试试这个

NSString *identifier = [[dictionary valueForKey:@"id"]stringvalue];

关于ios - 创建地理围栏时 NSCFNumber getCString maxLength 编码错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24670443/

有关ios - 创建地理围栏时 NSCFNumber getCString maxLength 编码错误的更多相关文章

  1. ruby - 如何在 Ruby 中顺序创建 PI - 2

    出于纯粹的兴趣,我很好奇如何按顺序创建PI,而不是在过程结果之后生成数字,而是让数字在过程本身生成时显示。如果是这种情况,那么数字可以自行产生,我可以对以前看到的数字实现垃圾收集,从而创建一个无限系列。结果只是在Pi系列之后每秒生成一个数字。这是我通过互联网筛选的结果:这是流行的计算机友好算法,类机器算法:defarccot(x,unity)xpow=unity/xn=1sign=1sum=0loopdoterm=xpow/nbreakifterm==0sum+=sign*(xpow/n)xpow/=x*xn+=2sign=-signendsumenddefcalc_pi(digits

  2. python - 如何使用 Ruby 或 Python 创建一系列高音调和低音调的蜂鸣声? - 2

    关闭。这个问题是opinion-based.它目前不接受答案。想要改进这个问题?更新问题,以便editingthispost可以用事实和引用来回答它.关闭4年前。Improvethisquestion我想在固定时间创建一系列低音和高音调的哔哔声。例如:在150毫秒时发出高音调的蜂鸣声在151毫秒时发出低音调的蜂鸣声200毫秒时发出低音调的蜂鸣声250毫秒的高音调蜂鸣声有没有办法在Ruby或Python中做到这一点?我真的不在乎输出编码是什么(.wav、.mp3、.ogg等等),但我确实想创建一个输出文件。

  3. ruby-on-rails - Rails 常用字符串(用于通知和错误信息等) - 2

    大约一年前,我决定确保每个包含非唯一文本的Flash通知都将从模块中的方法中获取文本。我这样做的最初原因是为了避免一遍又一遍地输入相同的字符串。如果我想更改措辞,我可以在一个地方轻松完成,而且一遍又一遍地重复同一件事而出现拼写错误的可能性也会降低。我最终得到的是这样的:moduleMessagesdefformat_error_messages(errors)errors.map{|attribute,message|"Error:#{attribute.to_s.titleize}#{message}."}enddeferror_message_could_not_find(obje

  4. ruby - 什么是填充的 Base64 编码字符串以及如何在 ruby​​ 中生成它们? - 2

    我正在使用的第三方API的文档状态:"[O]urAPIonlyacceptspaddedBase64encodedstrings."什么是“填充的Base64编码字符串”以及如何在Ruby中生成它们。下面的代码是我第一次尝试创建转换为Base64的JSON格式数据。xa=Base64.encode64(a.to_json) 最佳答案 他们说的padding其实就是Base64本身的一部分。它是末尾的“=”和“==”。Base64将3个字节的数据包编码为4个编码字符。所以如果你的输入数据有长度n和n%3=1=>"=="末尾用于填充n%

  5. ruby - 使用 Vim Rails,您可以创建一个新的迁移文件并一次性打开它吗? - 2

    使用带有Rails插件的vim,您可以创建一个迁移文件,然后一次性打开该文件吗?textmate也可以这样吗? 最佳答案 你可以使用rails.vim然后做类似的事情::Rgeneratemigratonadd_foo_to_bar插件将打开迁移生成的文件,这正是您想要的。我不能代表textmate。 关于ruby-使用VimRails,您可以创建一个新的迁移文件并一次性打开它吗?,我们在StackOverflow上找到一个类似的问题: https://sta

  6. ruby - 用逗号、双引号和编码解析 csv - 2

    我正在使用ruby​​1.9解析以下带有MacRoman字符的csv文件#encoding:ISO-8859-1#csv_parse.csvName,main-dialogue"Marceu","Giveittohimóhe,hiswife."我做了以下解析。require'csv'input_string=File.read("../csv_parse.rb").force_encoding("ISO-8859-1").encode("UTF-8")#=>"Name,main-dialogue\r\n\"Marceu\",\"Giveittohim\x97he,hiswife.\"\

  7. ruby-on-rails - 无法使用 Rails 3.2 创建插件? - 2

    我对最新版本的Rails有疑问。我创建了一个新应用程序(railsnewMyProject),但我没有脚本/生成,只有脚本/rails,当我输入ruby./script/railsgeneratepluginmy_plugin"Couldnotfindgeneratorplugin.".你知道如何生成插件模板吗?没有这个命令可以创建插件吗?PS:我正在使用Rails3.2.1和ruby​​1.8.7[universal-darwin11.0] 最佳答案 随着Rails3.2.0的发布,插件生成器已经被移除。查看变更日志here.现在

  8. ruby - 如何使用 RSpec::Core::RakeTask 创建 RSpec Rake 任务? - 2

    如何使用RSpec::Core::RakeTask初始化RSpecRake任务?require'rspec/core/rake_task'RSpec::Core::RakeTask.newdo|t|#whatdoIputinhere?endInitialize函数记录在http://rubydoc.info/github/rspec/rspec-core/RSpec/Core/RakeTask#initialize-instance_method没有很好的记录;它只是说:-(RakeTask)initialize(*args,&task_block)AnewinstanceofRake

  9. ruby - 为什么 SecureRandom.uuid 创建一个唯一的字符串? - 2

    关闭。这个问题需要detailsorclarity.它目前不接受答案。想改进这个问题吗?通过editingthispost添加细节并澄清问题.关闭8年前。Improvethisquestion为什么SecureRandom.uuid创建一个唯一的字符串?SecureRandom.uuid#=>"35cb4e30-54e1-49f9-b5ce-4134799eb2c0"SecureRandom.uuid方法创建的字符串从不重复?

  10. ruby-on-rails - 迷你测试错误 : "NameError: uninitialized constant" - 2

    我遵循MichaelHartl的“RubyonRails教程:学习Web开发”,并创建了检查用户名和电子邮件长度有效性的测试(名称最多50个字符,电子邮件最多255个字符)。test/helpers/application_helper_test.rb的内容是:require'test_helper'classApplicationHelperTest在运行bundleexecraketest时,所有测试都通过了,但我看到以下消息在最后被标记为错误:ERROR["test_full_title_helper",ApplicationHelperTest,1.820016791]test

随机推荐