I'm trying to read a spreadsheet worth of text and save NSAttributed string into a NSDictionary. The pasteboard guide got me going as far as
In items I have one single item of the type NSAttributedString.
I was somewhat hoping that each cell of the spreadsheet would turn into one attributedstring, magic, eh
Realizing that is not the case I'm trying to get my head around the data I actually have access to. I have tried to have only a very small bit of text in my clipboard (one cell worth). This allow me to get the one attributedstring I was hoping for.
The problem is that that attributedstring is not writing to disk properly.
If I hand craft an attributedstring it does save to disk so I'm thinking the one I read from clipboard is containing more than can be serialized or something like that.
My theory at this point is that I am getting one huge NSAttributedString from the clipboard that I will have to chop down to size somehow?
Anyone able to point me in the right direction here?
Code:
NSPasteboard *pasteBoard = [NSPasteboard generalPasteboard];
NSArray *classes = [[NSArray alloc] initWithObjects:[NSAttributedString class], [NSString class], nil];
NSDictionary *options = [[NSDictionary alloc] init];
NSArray *items = [pasteBoard readObjectsForClasses:classes options:options];
In items I have one single item of the type NSAttributedString.
I was somewhat hoping that each cell of the spreadsheet would turn into one attributedstring, magic, eh
Realizing that is not the case I'm trying to get my head around the data I actually have access to. I have tried to have only a very small bit of text in my clipboard (one cell worth). This allow me to get the one attributedstring I was hoping for.
The problem is that that attributedstring is not writing to disk properly.
Code:
NSAttributedString *str = [items lastObject];
NSDictionary *dict = @{@"testString": str};
if (![dict writeToFile:@"/Users/dantastic/Desktop/out.plist" atomically:NO]) {
NSLog(@"Fail...");
}
If I hand craft an attributedstring it does save to disk so I'm thinking the one I read from clipboard is containing more than can be serialized or something like that.
My theory at this point is that I am getting one huge NSAttributedString from the clipboard that I will have to chop down to size somehow?
Anyone able to point me in the right direction here?