- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
Xcode 6.4
Swift 1.2
我正在尝试迭代用户联系人,并为每个有电子邮件的联系人迭代电子邮件。问题是,在将电子邮件转换为字符串而不是将其作为 String 对象时,我收到的电子邮件是 errorType。
我的问题是,为什么会这样?
为什么 EmailID 没有被识别为 String?
这是我的代码:
let allContacts = ABAddressBookCopyArrayOfAllPeople(self.addressBookRef).takeRetainedValue() as Array
for record in allContacts
{
let currentContact: ABRecordRef = record;
let emailMultiValue:ABMultiValueRef = ABRecordCopyValue(currentContact, kABPersonEmailProperty).takeRetainedValue() as ABMultiValueRef
if ABMultiValueGetCount(emailMultiValue) > 0 {
let emailAddresses: NSArray = ABMultiValueCopyArrayOfAllValues(emailMultiValue).takeUnretainedValue() as NSArray
for email :AnyObject in emailAddresses {
if let emailID = email as? String{
//EmailID is <<errorType>>
println(emailID) //actually prints the email
}
}
}
}
编辑:
我试图用那一行替换 emailAddressed。
let emailAddresses: [String] = ABMultiValueCopyArrayOfAllValues(emailMultiValue).takeUnretainedValue() as! [String]
但是,我仍然遇到同样的错误。
谢谢!
最佳答案
好的,这可以通过迭代索引而不是元素来解决
for i in 0..<emailAddresses.count {
let email:String = emailAddresses[i]; //email is actually a string now
}
如果有人知道为什么迭代元素会产生错误类型我真的很想知道
关于ios - Swift Address Book,迭代电子邮件获取错误类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31920340/
我正在为 MIT OCW 类(class)做一些事情,它要求编写一个“图书馆”类(class)。现在我有这个: #include using namespace std; class Book{
ExcelWorkbook = py.load_workbook(FilePath) writer = pd.ExcelWriter(FilePath, engine = 'openpyxl') wr
我是 C++ 的学习者,我对构造函数和析构函数感兴趣。我编译了下面的代码,它返回了对 Book::~Book() 错误的 undefined reference 。但是当我注释掉析构函数时,它工作正常
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我正在使用 Google Books API在我的 Angular 项目中。我有书籍的不同静态类别的列表。单击特定类别时,我想从 Google Books API 获取搜索类别的书籍。 Google
我不知道如何做一些应该非常简单的事情。 我有两个实体:书架和书。一个书架可以放一本或多本书。这些实体中的每一个都有一个相应的 JpaRepository 暴露为使用 Spring Data Rest
我需要从 Booking.com 系统获取特定住宿的评分值。是否有 API 可以提供总体评分等信息以及系统中列出的属性的其他有用信息? 最佳答案 如果有人有同样的问题,我会简短地回答 - bookin
我需要从 Booking.com 系统获取特定住宿的评分值。是否有 API 可以提供总体评分等信息以及系统中列出的属性的其他有用信息? 最佳答案 如果有人有同样的问题,我会简短地回答 - bookin
有没有一种简单的方法可以使用 Google Book API 从 ISBN 获取 JSON 格式的图书封面? 最佳答案 您可以使用 isbn: 查询,如下所示: https://www.googlea
我是新手,所以这只是一个问题,我想知道哪个更有效,哪个提供最佳时间复杂度。 没有。 1 export default class BookingTabs extends Component {
在我一直在开发的应用程序中,我遇到了像 /books/:slug, :to => 'books#show', slug:/.*?/ 这样的路由。我很好奇这部分的作用 slug:/.*?/ ? 最佳答案
刚从使用 Books 应用程序示例的 Djangobook 教程中学习时,您通过多对多关系将 Book 与 Author 相关,并将 Book 与 Publisher 相关。您可以使用 p.book_
我刚启动 xcode 7 稳定版。在我当前的项目中,我正在从 web 服务下载图像。在 xcode 6.4 中工作正常。现在它没有显示任何图像并在日志中显示警告 -canOpenURL: failed
我在名为 DetailOrder 和 Book 的两个类中遇到映射问题。 问题如下所示。 Initial SessionFactory creation failed. org.hibernate.A
我正在尝试制作 CRUD+spring 应用程序来创建/删除/更新书籍。一切正常,但从数据库中搜索一本书。请帮忙。 @Controller public class BookController {
我完全是使用 CakePhp 的新手。我已经解决了一些问题,但我又对这个基本问题了如指掌。你能帮我解决这个问题吗? Notice (8): Undefined variable: books [APP
我在网上冲浪时遇到了一对多关系的问题,并且无法修复。我仔细检查了他们引用的 @Entity 声明 import javax.persistence.Entity; 之前我仅尝试单向 ManyToOne
刚开始在我的学校学习 node js。他们给了我们这个半完成的任务,我需要让下一个和上一个按钮起作用。但是,当我运行 index.html 时,控制台出现了一些错误。错误是: “获取 API 无法加载
我创建了一个网站,访问者可以使用turnjs 浏览一本书。我的页面是双页的 jpg,我希望它们能够动态加载。 代码如下: var flipbook = $('.flipbook'); flipboo
void displayInventory(const struct Book book[], const int size) { Idk y book[] 在 visual studio 中遇到
我是一名优秀的程序员,十分优秀!