John
John

Reputation: 10969

Check if a NSMutableDictionary is empty?

How can I tell if an NSMutableDictionary is empty in Objective-C?

Upvotes: 29

Views: 21541

Answers (2)

Ashu
Ashu

Reputation: 3523

I have also faced this problem. Below code is working for me on iOS 7.0.

[dict isKindOfClass:[NSNull class]];

Upvotes: 2

Jacob Relkin
Jacob Relkin

Reputation: 163258

Very simple, use the -count method inherited from NSDictionary:

NSMutableDictionary *dict = ...

BOOL isEmpty = ([dict count] == 0);

Upvotes: 74

Related Questions