Undeclared identifier __bridge on xcode
Asked Answered
F

1

10

I am trying to convert a CFUUIDRef to a NSString *.

Before, I used the following code, and worked fine.

CFStringRef str = CFUUIDCreateString(NULL, _uuid); # _uuid is of type CFUUIDRef
return (__bridge NSString *) str;

However, after a recent update on Xcode (or other thing that I didn't notice?), the above code gives me the error:

Use of undeclared identifier '__bridge'

So have I did something wrong? How could I solve it?

=== UPDATED ===

The full code:

+ (NSString *)uuidToString:(CFUUIDRef)_uuid {
  CFStringRef str = CFUUIDCreateString(NULL, _uuid); # _uuid is of type CFUUIDRef
  return (__bridge NSString *) str;
}

The uuid is generated by:

uuid = CFUUIDCreate(NULL);
Favor answered 15/8, 2011 at 9:53 Comment(2)
It complained that ARC does not allow the conversion...I am very new to xocde and don't know how to switch it on nor how to check if it is actually on.Favor
Turn ARC back on, if you want to use it, and show us the full code that its complaining about.Spumescent
T
20

__bridge is only defined with ARC (Automatic Reference Counting) enabled. It is used to "transfer objects in and out of ARC control". (Source)

To turn on ARC, go to your build settings and set Objective-C Automatic Reference Counting to Yes.

Or, if you do not want to use ARC, simply remove __bridge and it should work fine.

Toniatonic answered 31/8, 2011 at 23:31 Comment(1)
Hi I have used answer given here: #9342725 But getting errors. See my comments attached to that answer. Can you please help me out.Digitalize

© 2022 - 2024 — McMap. All rights reserved.