【发布时间】:2014-09-07 23:06:39
【问题描述】:
我正在运行一个 for 循环,但它找不到键的对象。我尝试在 if 语句中放入,看看它是否会有任何不同的结果,它不会记录
这是我的描述字典(它的日志)
{
(
"Apple's big event: Here's what to expect",
"WeChat helps Apple rack up bonus points in China",
"China Mobile Wants Apple's iPhone 6 to be a Blowout Success",
"What Will Apple Announce On September 9th? Software and Hardware Predictions For The iPhone 6 Event",
"Apple seeks old magic with new products",
"Five ways Apple's iPhone 6, iWatch launches may transform its business model",
"Apple's Plan To Kill PayPal Has Finally Become Clear (AAPL)",
"Apple's mojo on the line at unveiling",
"Will Apple",
"Apple adds new Flyover Tours Before the Big Launch for iOS 8 and OS X Yosemite ",
"Apple: watching for new directions",
"Apple Looks to Fashion World for iWatch Rollout",
"Apple website to live stream iPhone 6 launch event only for Apple devices",
"Is Apple planning a catwalk show for its iPhone/iWatch event?"
) = (
"After months of anticipation, the tech industry event of 2014 is upon us: Apple's product launch day. The tech giant has said almost nothing publicly about what's in store Tuesday, but industry observers have some ideas. Apple (AAPL, Tech30) is widely ...",
"BEIJING (Reuters) - Apple Inc has a lot for which to thank people like Deng. A Beijing-based quality analyst, she gave only her surname as she's embarrassed by how much money she spends playing mobile games on WeChat, a hugely popular messaging app ...",
"Apple Store in Pudong Shanghai. Source: Apple. Earlier this week the world's largest mobile carrier, China Mobile (NYSE: CHL ) , launched a pre-order site for the new, not-yet-released Apple (NASDAQ: AAPL ) iPhones. It wasn't the first time the carrier has ...",
"For fans and followers, journalists and analysts, to pop culture experts, celebrities, and late night chat show hosts, this Tuesday is going to be just like Christmas Day. While Apple has not said what will be announced at its September 9th event ...",
"With its highly awaited product launch this week, Apple is aiming for a new ",
"Apple is building a giant white cube outside of the Flint Center in Cupertino, CA. James Martin/CNET Apple's launch of the larger screen iPhone 6 and preview of iWatch or a similar wearable will aim to silence critics who contend the company's innovation ...",
"Apple has been quietly putting together a plan to blow open the mobile-payments industry, making major deals with credit-card companies in a move that could threaten the dominance of PayPal and other mobile-payment companies. These deals could make Apple ...",
"SAN FRANCISCO ",
"Just this past week we released our tour of Motorola",
"Apple knows they need to work on Maps. Improving their product started with faster turnarounds for updates and correcting errors and it continues with 3D flyover tours for more an more cities. A flyover tour will not make the Maps app more useful, but it ...",
"San Francisco (AFP) - Apple's mystery unveiling on Tuesday is expected to be a watershed moment for the California giant -- and the entire tech industry. Here are key things to watch for: - Can Tim Cook step up? - Chief executive Tim Cook will seek to ...",
"As intrigue builds around the mystery wearable product Apple is rumored to be launching next week, a new thread has been added to the story: high fashion. According to a new report, fashion journalists have been invited to Apple's Sept. 9 event, a move ...",
"The Apple launch event is the most teased event for a while now, and this made the Apple to want every Apple users to watch the video by streaming the event on the Apple website. Apple wants each and everyone on this globe to watch the launch event of the ...",
"There's a mysterious white building being built at the site of Apple's Tuesday event. Fashion bloggers have been invited. Ergo? Could there be a glorious catwalk lurking inside Apple's mystery cube? James Martin/CNET I took all my clothes to the dry ..."
);
}
这是我的一组钥匙
"Apple's big event: Here's what to expect",
"WeChat helps Apple rack up bonus points in China",
"What Will Apple Announce On September 9th? Software and Hardware Predictions For The iPhone 6 Event",
"Apple's Plan To Kill PayPal Has Finally Become Clear (AAPL)",
"China Mobile Wants Apple's iPhone 6 to be a Blowout Success",
"Apple's mojo on the line at unveiling",
"Five ways Apple's iPhone 6, iWatch launches may transform its business model",
"Apple seeks old magic with new products",
"Apple: watching for new directions",
"Apple Looks to Fashion World for iWatch Rollout",
"Will Apple",
"Apple adds new Flyover Tours Before the Big Launch for iOS 8 and OS X Yosemite ",
"Is Apple planning a catwalk show for its iPhone/iWatch event?",
"Apple Hires Australia"
当我运行这个 for 循环时,它总是不记录
for(NSString *string in _titleArray) {
if([_descriptionDict objectForKey:string]) {
NSLog(@"YES");
} else {
NSLog(@"NO");
}
}
编辑 由于第一个答案,知道字典是怎样的,所以问题继续。我如何把它变成一个普通的字典
**********编辑**************** 看来我正在根据答案正确地形成它们这是它的形成方式
descForTitles = [NSDictionary dictionaryWithObject:descriptions forKey:titleArr];
NSLog(@"Description Dict:%@", descForTitles);
但我仍然以相同的方式记录它
【问题讨论】:
-
了解如何阅读 NSLog。当您看到
{}字符时,表示字典,而()表示数组。所以很明显,您上面的字典只有一个条目,其中包含一个键,该键是您所有关键短语的数组。
标签: ios ios7 for-loop nsarray nsdictionary