[Q] is it shallow copy or deep copy? and why things are not retrieved well?
[Q] is it shallow copy or deep copy? and why things are not retrieved well?
- Subject: [Q] is it shallow copy or deep copy? and why things are not retrieved well?
- From: JongAm Park <email@hidden>
- Date: Sun, 17 Dec 2006 23:45:26 -0800
Hello.
With the NSDictionary I have some problems. Actually I guess I read
about whether it copies its content, i.e deep copy, or just its
reference, ie. shallow copy, but I can't find it again.
Ok. Here is the code. ( I'm sorry it is very wide. So, it may not be
displayed neatly on 80 column screen. )
for( i = 0; i < length ; i++ )
{
// NSLog( @"%@\n", [encodingStringArray_CF objectAtIndex:i] );
record = [NSDictionary dictionaryWithObjectsAndKeys:
// the 1st column
(NSString *)[encodingStringArray_CF objectAtIndex:i], @"CF_COL",
// the 2nd column
(NSString *) CFStringGetNameOfEncoding(encoding_constant[i]), @"CFNAME_COL",
// the 3rd column
(NSString *) CFStringCreateWithFormat( NULL, NULL, CFSTR("%u"),
encoding_constant[i] ), @"CFNUM_COL",
// the 4th column
[self
get_NSEncodingString_for_encoding:CFStringConvertEncodingToNSStringEncoding(encoding_constant[i])
], @"NS_COL",
// the 5th column
(NSString *) [NSString stringWithFormat:@"%u",
CFStringConvertEncodingToNSStringEncoding(encoding_constant[i])],
@"NSNUM_COL",
// the 6th column
(NSString *)[NSString localizedNameOfStringEncoding:
CFStringConvertEncodingToNSStringEncoding(encoding_constant[i]) ],
@"NSNAME_COL",
// the 7th column
(NSString
*)CFStringConvertEncodingToIANACharSetName(encoding_constant[i]),
@"IANA_COL",
// the 8th column
//CFStringCreateWithFormat(NULL, NULL, CFSTR(“test”)), //
CFStringConvertEncodingToWindowsCodepage(encoding_constant[i]) ),
(NSString *) CFStringCreateWithFormat(NULL, NULL, CFSTR("%u"),
CFStringConvertEncodingToWindowsCodepage(encoding_constant[i]) ),
@"WCP_COL",
nil];
// NSLog( @"%@\n", CFStringCreateWithFormat( NULL, NULL, CFSTR("%u"),
encoding_constant[i] ) );
[dataSource addObject:record];
NSLog( @"{%@, %@, %@, %@, %@, %@}\n", [record objectForKey:@"CF_COL"],
[record objectForKey:@"CFNUM_COL"],
[record objectForKey:@"NS_COL"], [record objectForKey:@"NSNUM_COL"],
[record objectForKey:@"IANA_COL"], [record objectForKey:@"WCP_COL"] );
}
Among those columns, the 3rd column causes the problem.
First, when it is printed out with the NSLog() function, it is displayed
as (NULL). For example, when it is "12", which is
kCFStringEncodingMacOriya, it is not displayed.
I intentionally didn't release the string created with
CFStringCreateWithFormat, worrying if the dictionaryWithObjectsAndKeys
method does shallow copy.
However ,it still doesn't display the value correctly.
So, can anyone tell me how the method keeps the content in the "array",
and why the value is not displayed?
Thank you very much.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden