NSAutoreleasepool in iOS app?

Hi,

when does Xojo for iOS use NSAutoreleasepools?

Like do you just let Apple do it in main loop?
Or do it yourself for each method?

The question is how soon I need to retain an autoreleased object from a declare.

Greetings
Christian

[quote=280491:@Christian Schmitz]Like do you just let Apple do it in main loop?
[/quote]

For the most part, this.

If “Xojo for iOS” uses ARC, then it shouldn’t matter

now I got an NSArray object from a declare.

I pass it to a method to convert to xojo array.
This queries count of array and returns some weird number.

Adding retain and release in the calling method where the original declare is fixes this so far.
Strange.

What does the Obj-C Selector giving the NSArray back look like?

“calendarsForEntityType:” from EventKit.

As this selector does not contain the words “alloc”, “new” or “copy”, you need to call retain (and release it later or add it to your own autorelease pool).

By the way this method returns an NSSet, not an NSArray.

/*!
@method calendarsForEntityType
@abstract Returns calendars that support a given entity type (reminders, events)
*/

  • (NSArray *)calendarsForEntityType:(EKEntityType)entityType __OSX_AVAILABLE_STARTING(__MAC_10_8,__IPHONE_6_0);

so it’s not a NSSet.

calendarsForEntityType:

I think he passes the pointer pointing to the array to another method in which he is doing the count. When such a pointer is handed over to another Xojo method the pointer gets invalid without retaining it first.

[quote=280505:@Christian Schmitz]This queries count of array and returns some weird number.

[/quote]

What number?

Querying count of the NSArray gives correct number in one method, but not in the called method.
As if the array would be gone in-between.

The number can be anything like -28764590