Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Chirone

macrumors 6502
Original poster
Mar 2, 2009
279
0
NZ
Hi guys,

I'm trying to get my project to play nicely with ARC but I have code where I create a CATextLayer using an NSAttributedString.

The problem is is that the app crashes on the device (but not simulator).
I don't know what I'm doing wrong...
here's some sample code from the project:
Code:
	CATextLayer *textLayer = [[CATextLayer alloc] init];
	textLayer.frame = layerFrame;
	textLayer.wrapped = YES;

	UIFont *a1Font = [UIFont systemFontOfSize:20];
	CTFontRef a1FontRef = CTFontCreateWithName((__bridge CFStringRef)a1Font.fontName, a1Font.pointSize, NULL);

	CGColorRef a1ColorRef = [UIColor blueColor].CGColor;
	NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:(__bridge_transfer  id)a1FontRef, (id)kCTFontAttributeName, a1ColorRef, (id)kCTForegroundColorAttributeName, nil];

	NSString *helpString = @"This is the help part";
	NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:helpString attributes:attributes];
	textLayer.string = attrString;


I'm putting __bridge and every permutation (I think) of __bridge, __bridge_transfer and __bridge_retained in various casting places but with no luck at all.


anyone know the correct way to do this?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.