Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

@{} 设置字典,导致元素随机减少 #1

Open

Description

UILabel *label = [UILabel new];
NSDictionary *dataDic = @{
@"123":@"123",
@"1232":@"1233",
@"1233":@"1243",
@"123e":@"123d",
@"12345": label.text,
@"1asd":@"123",
@"dfg":@"1233",
};
MYLog(@"-----%@",dataDic)
打印结果如下:
-----{
123 = 123;
1232 = 1233;
1233 = 1243;
123e = 123d;
}

NSDictionary+Safe

-(instancetype)initWithObjects_st:(id *)objects forKeys:(id *)keys count:(NSUInteger)count {
NSUInteger rightCount = 0;
for (NSUInteger i = 0; i < count; i++) {
if (!(keys[i] && objects[i])) {
///此处会导致字典元素减少较多
break;
}else{
rightCount++;
}
}
self = [self initWithObjects_st:objects forKeys:keys count:rightCount];
return self;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /