Copying an NSDictionary without empty values?

I'm trying to create an NSDictionary with the dictionaryWithDictionary method. However, my first NSDictionary A may have some keys with empty values. How can I create B that doesn't have any keys with empty values? I'm doing all of this for the purposes of populating a UITableView with rows that correspond to each non-empty key in the NSDictionary.

Answers


How about something like this:

NSMutableDictionary *destDictionary = [NSMutableDictionary dictionaryWithCapacity:[sourceDictionary count]];
NSEnumerator *keyEnumerator = [[sourceDictionary allKeys] objectEnumerator];
id key;
while ( key = [keyEnumerator nextObject] )
    {
    NSString *object = [sourceDictionary objectForKey:key];
    if ([object length] == 0)
        continue;
    [destDictionary setObject:object forKey:key];
    }

Need Your Help

Inline implemented interface indentation

java eclipse interface indentation

I've noticed that when I inline implement an interface in the class body itself, ie. not inside a method,

Not able to upload image to server using Httprequest library

android httprequest multipartform-data

I have created an app in which user select an image from gallery and that image is uploaded to the server.I tried doing it using Httprequest Library.But i m not being able to upload it.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.