我正在尝试解析一个JSON字符串,但它出现了SIGABRT错误。
我正在使用的代码:
NSString *test = @'{"notifications":[{"id":"fae9a890-2791-46e2-ad9c-5a72f602a2e8","created":"2017-06-17T21:57:28+00:00","thread_id":3964,"reply_id":null,"thread":{"id":3964,"subject":"[CakePHP] Pagination"},"users_from":{"username":"Royal"},"content":"has posted a reply in"},{"id":"00732627-f23e-423e-b885-add968575972","created":"2017-06-17T20:08:05+00:00","thread_id":3964,"reply_id":79478,"thread":{"id":3964,"subject":"[CakePHP] Pagination"},"users_from":{"username":"Royal"},"content":"has quoted you in"}]}';
NSError *error;
NSMutableDictionary *allCourses = [NSJSONSerialization JSONObjectWithData:test
options:kNilOptions
error:&error];
if( error )
{
NSLog(@"%@", [error localizedDescription]);
}
else {
NSArray *monday = allCourses[@"notifications"];
for ( NSDictionary *theCourse in monday )
{
NSLog(@"----");
NSLog(@"Title: %@", theCourse[@"subject"] );
NSLog(@"Id: %@", theCourse[@"id"] );
NSLog(@"----");
}
}
感谢。
答案 0 :(得分:0)
错误在你的NSString声明中:
for toppings in self.toppings {
if self.selectedDrink.name == "Tea" {
if toppings.limit == "C" {
self.toppings.remove(at: toppings)
}
}
}
这是错误的。
NSString必须始终使用以下格式:@" bla bla bla"。
您需要在测试字符串中加入双引号的转义符,如此
SELECT m.*
FROM (SELECT m.*,
(@rn := if(@a = a.id, @rn + 1,
if(@a := a.id, 1, 1)
)
) as rn
FROM tags t JOIN
artists a
ON t.artist_id = a.id JOIN
mp3s m
ON m.id = t.mp3_id CROSS JOIN
(SELECT @a := -1, @rn := 0) params
WHERE . . .
ORDER BY a.id, m.date DESC
) m
WHERE rn <= 3;