Re: [iPhone] CFAttributedStringRef autorelease - not possible?

2009-07-21 Thread Dave Camp

On Jul 19, 2009, at 9:13 AM, Michael Hoy wrote:


NSString *m_scanString = @This is a test.;
CFDictionaryRef emptyDic = (CFDictionaryRef)[NSDictionary dictionary];
CFAttributedStringRef attString =  
CFAttributedStringCreate(kCFAllocatorDefault,  
(CFStringRef)m_scanString, emptyDic);
CFMutableAttributedStringRef linkifiedString =  
CFAttributedStringCreateMutableCopy(kCFAllocatorDefault, 0,  
attString);
NSLog(@%@, (NSString  
*)CFAttributedStringGetString(linkifiedString));

[(id)linkifiedString autorelease];

Testing in a Mac OS 10.5 SDK, this code works. In the iPhone 3.1  
SDK, the last line of code (calling autorelease on  
CFMutableAttributedStringRef) gives EXC_BAD_ACCESS. Everything else  
works as expected.


Is CFAttributedStringRef not castable to id or NSObject* in the  
iPhone environment?


Attributed strings are not supported on the iPhone.

Dave
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please 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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [iPhone] CFAttributedStringRef autorelease - not possible?

2009-07-21 Thread Michael Hoy
I know it doesn't support NSAttributedString. However,  
CFAttributedStringRef is supported. (That's why I'm using it.) The  
documentation reads:


iPhone OS Note: While Core Foundation on iPhone OS contains  
CFAttributedString, there are no additions to the APIs in UIKit to add  
specific attributes such as font, style, or color, and there are no  
APIs to draw attributed strings.


My question is about casting CFAttributedStringRef to id, which  
appears not to work in certain circumstances. For example, adding an  
(id)CFAttributedStringRef to an NSMutableArray appears to work fine...  
CFGetRetainCount() reports an increase and decrease in the retain  
count after adding/removing.


~Michael

On Jul 21, 2009, at 11:20 AM, Dave Camp wrote:


On Jul 19, 2009, at 9:13 AM, Michael Hoy wrote:


NSString *m_scanString = @This is a test.;
CFDictionaryRef emptyDic = (CFDictionaryRef)[NSDictionary  
dictionary];
CFAttributedStringRef attString =  
CFAttributedStringCreate(kCFAllocatorDefault,  
(CFStringRef)m_scanString, emptyDic);
CFMutableAttributedStringRef linkifiedString =  
CFAttributedStringCreateMutableCopy(kCFAllocatorDefault, 0,  
attString);
NSLog(@%@, (NSString  
*)CFAttributedStringGetString(linkifiedString));

[(id)linkifiedString autorelease];

Testing in a Mac OS 10.5 SDK, this code works. In the iPhone 3.1  
SDK, the last line of code (calling autorelease on  
CFMutableAttributedStringRef) gives EXC_BAD_ACCESS. Everything else  
works as expected.


Is CFAttributedStringRef not castable to id or NSObject* in the  
iPhone environment?


Attributed strings are not supported on the iPhone.

Dave


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please 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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [iPhone] CFAttributedStringRef autorelease - not possible?

2009-07-21 Thread Greg Guerin

Michael Hoy wrote:

I know it doesn't support NSAttributedString. However,  
CFAttributedStringRef is supported. (That's why I'm using it.) The  
documentation reads:


iPhone OS Note: While Core Foundation on iPhone OS contains  
CFAttributedString, there are no additions to the APIs in UIKit to  
add specific attributes such as font, style, or color, and there  
are no APIs to draw attributed strings.


My question is about casting CFAttributedStringRef to id, which  
appears not to work in certain circumstances. For example, adding  
an (id)CFAttributedStringRef to an NSMutableArray appears to work  
fine... CFGetRetainCount() reports an increase and decrease in the  
retain count after adding/removing.


Wrap CFAttributedStringRef (or CFMutableAttributedStringRef) in a  
class of your own making.  Then you can be sure it will autorelease  
correctly.


All it would need is a ref method/property that returns  
CFAttributedStringRef (or CFMutableAttributedStringRef), and a  
dealloc to call the appropriate CF function on the ref.  This seems  
almost trivial to write, and would probably take less time than it  
took to create the example showing the failure.


  -- GG

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please 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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


[iPhone] CFAttributedStringRef autorelease - not possible?

2009-07-20 Thread Michael Hoy

Here's some code:

NSString *m_scanString = @This is a test.;
CFDictionaryRef emptyDic = (CFDictionaryRef)[NSDictionary dictionary];
CFAttributedStringRef attString =  
CFAttributedStringCreate(kCFAllocatorDefault,  
(CFStringRef)m_scanString, emptyDic);
CFMutableAttributedStringRef linkifiedString =  
CFAttributedStringCreateMutableCopy(kCFAllocatorDefault, 0, attString);

NSLog(@%@, (NSString *)CFAttributedStringGetString(linkifiedString));
[(id)linkifiedString autorelease];

Testing in a Mac OS 10.5 SDK, this code works. In the iPhone 3.1 SDK,  
the last line of code (calling autorelease on  
CFMutableAttributedStringRef) gives EXC_BAD_ACCESS. Everything else  
works as expected.


Is CFAttributedStringRef not castable to id or NSObject* in the iPhone  
environment?


Thanks,
~ Michael Hoy
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please 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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com