English 中文(简体)
Objective-C Distributed Objects with ARC sever and 32bit proxy?
原标题:

I have a 64bit application using ARC, that is serving up a distributed object. The application that uses the proxy object is a 32bit application, so it s not using ARC. Is this going to create problems for me?

I also want to reuse my classes from the 64bit/ARC application, inside my 32bit application. If those are ARC, how can I integrate them in a non-ARC application?

最佳回答

I would not recommend doing this. Using distributed objects between the 32-bit and 64-bit runtimes appears to be possible, but it has some problems. From the Foundation Constants Reference:

Prior to Mac OS X v10.5, NSNotFound was defined as 0x7fffffff. For 32-bit systems, this was effectively the same as NSIntegerMax. To support 64-bit environments, NSNotFound is now formally defined as NSIntegerMax. This means, however, that the value is different in 32-bit and 64-bit environments. You should therefore not save the value directly in files or archives. Moreover, sending the value between 32-bit and 64-bit processes via Distributed Objects will not get you NSNotFound on the other side. This applies to any Cocoa methods invoked over Distributed Objects and which might return NSNotFound, such as the indexOfObject: method of NSArray (if sent to a proxy for an array).

Sure, you can do some basic sanity checks on -[NSArray indexOfObject:], but what if any library or framework you use (which includes Cocoa and Foundation) uses an API that can return NSNotFound? Not to mention that this is only one problem that can occur communicating between 32 and 64-bit runtimes, and the other problems might not be documented.

I tend to shy away from distributed objects because of some of their other problems, but even if you were determined to use them, this seems like a deal breaker to me.

I do not believe that there is anything intrinsic to ARC that would prevent you from using ARC and Distributed Objects together. However, memory management with distributed objects can be tricky. If you needed to break the standard retain-release rules to work around a memory leak between the client and the server, ARC would not let you do so. You d need to be extra careful to architect your server to avoid this.

Finally, since you can t use ARC in your 32-bit runtime, you ll have to write manual retain/release code for those classes. If you plan to eventually move away from the non-ARC code, you can advantage of __has_feature(objc_arc). Otherwise it s probably better to not use ARC on the files you plan to share between the 32 and 64-bit applications. ARC can be enabled or disabled on a per-file basis.

问题回答

暂无回答




相关问题
Asynchronous request to the server from background thread

I ve got the problem when I tried to do asynchronous requests to server from background thread. I ve never got results of those requests. Simple example which shows the problem: @protocol ...

objective-c: Calling a void function from another controller

i have a void, like -(void) doSomething in a specific controller. i can call it in this controller via [self doSomething], but i don t know how to call this void from another .m file. I want to call ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

NSUndoManager and runModalForWindow:

I have a simple Core Data app which displays a list of entities in the main window. To create or add new entities, I use a second modal window with a separate managed object context so changes can be ...

NSMutableArray values becoming "invalid"

I m trying to show a database information in a tableview and then the detailed information in a view my problem is as follow: I created a NSMutableArray: NSMutableArray *myArray = [[NSMutableArray ...

iPhone numberpad with decimal point

I am writing an iPhone application which requires the user to enter several values that may contain a decimal point (currency values, percentages etc.). The number of decimal places in the values ...

热门标签