System.get_property('phone_id') 是否总是返回一个值?
文档没有提及可能的返回值。我在源代码中查找了实现,但找不到它。
我编写了一个简单的应用程序并在 iPhone 模拟器中运行它,但没有显示任何值。该应用程序是通过运行 rhogen app phone_id
创建的。然后,我在调用 super
之前将以下行添加到 app/application.rb
文件中:
@phoneId = System.get_property('phone_id')
然后我将此行添加到 app/index.erb< /code>:
<p>Phone id = <span><%= @phoneId %></span></p>
我知道模拟器将返回一个唯一标识符,因为我编写了一个实际的 iOS 应用程序,该应用程序仅使用以下代码将唯一标识符写入标签:
[idLabel setText:[[UIDevice currentDevice] uniqueIdentifier]];
因为我不了解 Ruby,而且我特别不了解不认识罗德,我不确定罗德测试是否我编写的应用程序工作正常。因此,我不知道对 System.get_property 的调用是否正常工作,或者是否确实应该返回标识符。
因此我的问题是,System.get_property('phone_id')
总是返回一个值吗?如果是这样,该值是否保证是唯一的?或者在某些情况下该方法会返回nil?
The documentation says nothing about possible return values. I have looked for the implementation in the source code, but I am unable to find it.
I wrote a simple application and ran it in the iPhone Simulator, but no value is shown. The application was created by running rhogen app phone_id
. I then added the following line to the app/application.rb
file just before the call to super
:
@phoneId = System.get_property('phone_id')
Then I added this line to app/index.erb
:
<p>Phone id = <span><%= @phoneId %></span></p>
I know that the simulator will return a unique identifier because I wrote an actual iOS application that merely writes the unique identifier to a label with the following bit of code:
[idLabel setText:[[UIDevice currentDevice] uniqueIdentifier]];
Since I don't know Ruby, and I particularly don't know Rhodes, I am unsure if the Rhodes test application I wrote is working correctly. So, I don't know if the call to System.get_property
is working as it should or if it should really be returning an identifier.
Thus my question, does System.get_property('phone_id')
always return a value? If so, is that value guaranteed to be unique? Or are there cases where the method will return nil
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据消息 cb41fb9718773a21 和 0d4ff1aaaaa9e560 在 Rhomobile Google 群组中,此方法不保证返回除
nil
之外的任何值。因此,您不能依赖System.get_property('phone_id')
来返回应用程序的唯一标识符。According to messages cb41fb9718773a21 and 0d4ff1aaaaa9e560 on the Rhomobile Google group, this method is not guaranteed to return any value other than
nil
. Thus you cannot rely onSystem.get_property('phone_id')
to return a unique identifier for your application.