Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Ok. Let me explain the solution. As you said in the comment, you are using the library throughout the app. </p> <p>So, I think the best solution to your problem is create the <a href="http://www.cocoawithlove.com/2008/12/ordereddictionary-subclassing-cocoa.html" rel="nofollow">OrderedDictionary from CocoaWithLove</a>. The OrderedDictionary contains an NSMutableDictionary and an NSMutableArray for the keys inside it, to keep track of the order of the keys. </p> <p>The you can create a Category of FMResultSet:</p> <p><strong>FMResultSet+OrderedDict.h</strong></p> <pre><code>#import &lt;Foundation/Foundation.h&gt; #import "FMResultSet.h" #import "OrderedDictionary.h" @interface FMResultSet(OrderedDict) - (OrderedDictionary*)resultOrderDictionary; @end </code></pre> <p><strong>FMResultSet+OrderedDict.m</strong></p> <pre><code>#import "FMResultSet+OrderedDict.h" #import "OrderedDictionary.h" #import "FMDatabase.h" @implementation FMResultSet(OrderedDict) - (OrderedDictionary*)resultOrderDictionary { NSUInteger num_cols = (NSUInteger)sqlite3_data_count([_statement statement]); if (num_cols &gt; 0) { OrderedDictionary *dict = [OrderedDictionary dictionaryWithCapacity:num_cols]; int columnCount = sqlite3_column_count([_statement statement]); int columnIdx = 0; for (columnIdx = 0; columnIdx &lt; columnCount; columnIdx++) { NSString *columnName = [NSString stringWithUTF8String:sqlite3_column_name([_statement statement], columnIdx)]; id objectValue = [self objectForColumnIndex:columnIdx]; [dict setObject:objectValue forKey:columnName]; } return dict; } else { NSLog(@"Warning: There seem to be no columns in this set."); } return nil; } @end </code></pre> <p>And in your code do this:</p> <pre><code>NSMutableArray *results = [NSMutableArray array]; while ([Loginresults next]) { [results addObject:[Loginresults resultOrderDictionary]]; } requestdata = [NSJSONSerialization dataWithJSONObject:results options:0 error:&amp;jsonError]; </code></pre> <p>If you want I can upload my Project Test to github.</p> <p>EDIT: The <a href="https://github.com/dcorbatta/StackoverflowTest" rel="nofollow">code</a> now is uploaded.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload