NSTableView and NSArrayController with Handles Content As Compound Value - won't select new items in Table View

2013-02-17 Thread Alex Rainchik
Hello,

I have a typical NSTableView and NSArrayController confguration, with Array
Controller's Content Array bound to NSMutableArray called usersArray

What I'm trying to do is to have an KVO observer setup, so every time
usersArray is changed I dump it to NSUsersDefault as a way to store it for
the
future use.

What I found out is that if I do not select Handles Content As Compound
Value
option in Content Array binding - my observer is called when objects are
added
or deleted in Table View, but not when they are modified.

If I enable Handles Content As Compound Value - everything works fine,
with
the exception of new objects in Table View are not getting selected on
insertion. Is there a way to fix that? I'm adding new objects in Table View
by
linking Add button to add: method in Array Controller.

I've tried binding Array Controller's Content Array directly to Shared Users
Defaults with exactly the same results - have to enable Handles Content As
Compound Value option and that breaks highlighting/selecting newly inserted
object in Table View.

Please advise :)

Thank you!
___

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

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


Re: iOS Document Interaction Technology

2013-02-17 Thread Damian Carrillo
Koko,

You may be missing UTExportedTypeDeclarations. 
https://developer.apple.com/library/ios/#documentation/FileManagement/Conceptual/understanding_utis/understand_utis_declare/understand_utis_declare.html
 explains the process. 

If you're using the Info tab in Xcode to declare your Document Type(s), you can 
probably expect to have a corresponding entry for each one in the Exported UTIs 
section.

Damian

On Feb 14, 2013, at 12:29 PM, koko k...@highrolls.net wrote:

 
 On Feb 13, 2013, at 6:30 PM, Jerry Krinock je...@ieee.org wrote:
 
 But I'm only writing as an iPad user.
 
 FYI: 
 
 Document Interaction Programming Topics for iOS
 
 Registering the File Types Your App Supports
 
 If your app is capable of opening specific types of files, you should 
 register that support with the system. This allows other apps, through the 
 iOS document interaction technology, to offer the user the option to hand off 
 those files to your app.
 To declare its support for file types, your app must include the 
 CFBundleDocumentTypes key in its Info.plistproperty list file. (See “Core 
 Foundation Keys”.) The system adds this information to a registry that other 
 apps can access through a document interaction controller.
 
 ___
 
 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:
 https://lists.apple.com/mailman/options/cocoa-dev/damiancarrillo%40me.com
 
 This email sent to damiancarri...@me.com


___

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

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

cocoa bindings performance

2013-02-17 Thread Maximilian Marcoll

Hi everyone!

I have a problem with bindings, or so it seems. 

In my application, I need to programmatically create lots of small views 
embedded in a big view.
Think of them as draggable items on a plane.

Thus far I'm controling the views using bindings. Four bindings per view to be 
precise. 
The bindings bind the views to controller objects, which are connected to my 
model objects.
The bindings are used to change the model objects' values according to their 
size and their position on the plane and vice versa.

If I the app has to manage only a small number of items everything works fine. 
But when there are very many items (views) to create, the app slows down 
considerably and is basically unuseable.

I assumed that I somehow wrote very unefficient code in my views or something 
like that and I used the Time Profiler to see what actually is the most time 
consuming operation.
It appears that the method consuming 90% of the time is:
-[NSObject(NSKeyValueBindingCreation) bind:toObject:withKeyPath:options:] .

Now, I'm obviously missing something here. What I want is to have lots of small 
rectangular items on a plane. 
Hundreds, or even thousands of them.
I want to be able to drag them around, change their size and have those 
properties change values in my model. 

It seems very unlikely to me that creating bindings for those views is actually 
that time consuming by itself.
Or is it?

Any help is much appreciated!

Thank you!!





___

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

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


Re: Multiple methods named...

2013-02-17 Thread Michael Bauer
I must misunderstand what you are trying to accomplish. From the description of 
Strict Selector Matching:

Warn if multiple methods with differing argument and/or return types are found 
for a given selector when attempting to send a message using this selector to a 
receiver of type id or Class.  When this setting is disabled, the compiler 
will omit such warnings if any differences found are confined to types which 
share the same size and alignment. 

To me it seems that this is what you are trying to accomplish: use the same 
method name passed to a type id whose class is determined at runtime and each 
method from the respective class would do something different.

FWIW I just used a default command line template for the project.

Regards,
-mike
___

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

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


Re: cocoa bindings performance

2013-02-17 Thread Tom Davie
Sorry I can't be of more direct help, but…

Cocoa bindings are unfortunately one of many tools that apple produces with the 
thought we can make this small task I do repeatedly much easier in their 
head, that typically doesn't cover the general case.  They're enormously 
productive if all you're doing is one of the obvious, standard UIs.  
Unfortunately, as soon as you want to do something more complex, that typically 
breaks down with almost any structure.  This is due to 3 things:
1) Debugging them is near impossible – you end up wasting as much time as you 
save trying to track down what's wrong.
2) Lack of flexibility – you eventually hit a wall where bindings simply can't 
do what you want any more and need to rewrite everything.
3) Performance – you can't tune anything with these technologies typically.

My advice would simply be to steer well clear of bindings (along with a couple 
of other techs that supposedly make life easier, like CoreData and Storyboards).

Thanks

Tom Davie

On 15 Feb 2013, at 19:42, Maximilian Marcoll m...@dis.playce.info wrote:

 
 Hi everyone!
 
 I have a problem with bindings, or so it seems. 
 
 In my application, I need to programmatically create lots of small views 
 embedded in a big view.
 Think of them as draggable items on a plane.
 
 Thus far I'm controling the views using bindings. Four bindings per view to 
 be precise. 
 The bindings bind the views to controller objects, which are connected to my 
 model objects.
 The bindings are used to change the model objects' values according to their 
 size and their position on the plane and vice versa.
 
 If I the app has to manage only a small number of items everything works 
 fine. 
 But when there are very many items (views) to create, the app slows down 
 considerably and is basically unuseable.
 
 I assumed that I somehow wrote very unefficient code in my views or something 
 like that and I used the Time Profiler to see what actually is the most time 
 consuming operation.
 It appears that the method consuming 90% of the time is:
 -[NSObject(NSKeyValueBindingCreation) bind:toObject:withKeyPath:options:] .
 
 Now, I'm obviously missing something here. What I want is to have lots of 
 small rectangular items on a plane. 
 Hundreds, or even thousands of them.
 I want to be able to drag them around, change their size and have those 
 properties change values in my model. 
 
 It seems very unlikely to me that creating bindings for those views is 
 actually that time consuming by itself.
 Or is it?
 
 Any help is much appreciated!
 
 Thank you!!
 
 
 
 
 
 ___
 
 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:
 https://lists.apple.com/mailman/options/cocoa-dev/tom.davie%40gmail.com
 
 This email sent to tom.da...@gmail.com


___

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

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

Re: Problem with NSPersistentStore

2013-02-17 Thread Mike Abdullah
Thinking about it more, your method doesn't really make sense. In order to use 
a context it must be associated with a persistent store coordinator, in order 
to know its model. So it doesn't make sense to create the coordinator lazily. 
Instead, make *adding the store* be the lazy bit

Sent from my iPad

On 16 Feb 2013, at 19:06, Laurent Daudelin laur...@nemesys-soft.com wrote:

 Hey Mike.
 
 No assertions have ever been fired, which I thought was weird a bit as well. 
 BTW, this is on iOS, not Mac OS X if that makes any difference.
 
 -Laurent.
 -- 
 Laurent Daudelin
 AIM/iChat/Skype:LaurentDaudelin   
 http://www.nemesys-soft.com/
 Logiciels Nemesys Software
 laur...@nemesys-soft.com
 
 On Feb 16, 2013, at 02:00, Mike Abdullah cocoa...@mikeabdullah.net wrote:
 
 
 On 16 Feb 2013, at 00:37, Laurent Daudelin laur...@nemesys-soft.com wrote:
 
 I got a few crash reports from users that have a problem with my CoreData 
 app.
 
 Given the following code:
 
 /*
 Returns the persistent store coordinator for the application.
 If the coordinator doesn't already exist, it is created and the 
 application's store added to it.
 */
 - (NSPersistentStoreCoordinator *)persistentStoreCoordinator
 {
   if (_persistentStoreCoordinator == nil) {
   NSURL *storeUrl = [NSURL fileURLWithPath:self.persistentStorePath];
   _persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] 
 initWithManagedObjectModel:[NSManagedObjectModel 
 mergedModelFromBundles:nil]];
   NSError *error = nil;
   NSPersistentStore *persistentStore = [_persistentStoreCoordinator 
 addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl 
 options:nil error:error];
   NSAssert3(persistentStore != nil, @%s at %d: Unhandled error adding 
 persistent store: %@, __FUNCTION__, __LINE__, [error 
 localizedDescription]);
 NSLog(@Created persistent store '%@' at URL %@, 
 persistentStore, storeUrl);
   }
   return _persistentStoreCoordinator;
 }
 
 When the MOC tries to perform a save, an exception is generated:
 
 Exception reason
 
 This NSPersistentStoreCoordinator has no persistent stores. It cannot 
 perform a save operation.
 
 Stacktrace
 
 PRIMARY THREAD THREAD 0
 
 • 0 CoreFoundation 0x356212a3 __exceptionPreprocess + 163
 • 1 libobjc.A.dylib 0x3393197f objc_exception_throw + 31
 • 2 CoreData 0x36f2dfef -[NSPersistentStoreCoordinator 
 executeRequest:withContext:error:] + 299
 • 3 CoreData 0x36f862d3 -[NSManagedObjectContext save:] + 731
 
 How can the persistent store not being existing?
 
 Well you whacked in some assertions that failures never happen (generally a 
 bad idea for disk access. It *is* going to fail sometime). Have those 
 assertions fired?
 
___

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

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

Re: cocoa bindings performance

2013-02-17 Thread Mike Abdullah


Sent from my iPad

On 15 Feb 2013, at 19:42, Maximilian Marcoll m...@dis.playce.info wrote:

 
 Hi everyone!
 
 I have a problem with bindings, or so it seems. 
 
 In my application, I need to programmatically create lots of small views 
 embedded in a big view.
 Think of them as draggable items on a plane.
 
 Thus far I'm controling the views using bindings. Four bindings per view to 
 be precise. 
 The bindings bind the views to controller objects, which are connected to my 
 model objects.
 The bindings are used to change the model objects' values according to their 
 size and their position on the plane and vice versa.
 
 If I the app has to manage only a small number of items everything works 
 fine. 
 But when there are very many items (views) to create, the app slows down 
 considerably and is basically unuseable.
 
 I assumed that I somehow wrote very unefficient code in my views or something 
 like that and I used the Time Profiler to see what actually is the most time 
 consuming operation.
 It appears that the method consuming 90% of the time is:
 -[NSObject(NSKeyValueBindingCreation) bind:toObject:withKeyPath:options:] .

Ok, and what inside of this method is taking up the time?

In my experience the act of creating or tearing down a lot of observations is 
pretty slow; can you avoid making so many bindings in one go? Perhaps recycle 
existing bindings rather than recreating anew?

Secondly, what do your model objects inherit from? If they're direct NSObject 
subclasses, an easy win for KVO performance is to implement 
-setObservationInfo: and getter method too.
 
 Now, I'm obviously missing something here. What I want is to have lots of 
 small rectangular items on a plane. 
 Hundreds, or even thousands of them.
 I want to be able to drag them around, change their size and have those 
 properties change values in my model. 
 
 It seems very unlikely to me that creating bindings for those views is 
 actually that time consuming by itself.
 Or is it?
 
 Any help is much appreciated!
 
 Thank you!!
 
 
 
 
 
 ___
 
 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:
 https://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40mikeabdullah.net
 
 This email sent to cocoa...@mikeabdullah.net

___

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

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


Re: NSTableView and NSArrayController with Handles Content As Compound Value - won't select new items in Table View

2013-02-17 Thread Keary Suska

On Feb 12, 2013, at 11:26 PM, Alex Rainchik wrote:

 Hello,
 
 I have a typical NSTableView and NSArrayController confguration, with Array
 Controller's Content Array bound to NSMutableArray called usersArray
 
 What I'm trying to do is to have an KVO observer setup, so every time
 usersArray is changed I dump it to NSUsersDefault as a way to store it for
 the
 future use.
 
 What I found out is that if I do not select Handles Content As Compound
 Value
 option in Content Array binding - my observer is called when objects are
 added
 or deleted in Table View, but not when they are modified.
 
 If I enable Handles Content As Compound Value - everything works fine,
 with
 the exception of new objects in Table View are not getting selected on
 insertion. Is there a way to fix that? I'm adding new objects in Table View
 by
 linking Add button to add: method in Array Controller.
 
 I've tried binding Array Controller's Content Array directly to Shared Users
 Defaults with exactly the same results - have to enable Handles Content As
 Compound Value option and that breaks highlighting/selecting newly inserted
 object in Table View.


This seems to be an issue with NSArrayController. The easiest way around it 
seems to me to use your own method for -add: and not rely on the 
NSArrayController behavior.

HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business


___

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

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


Re: Binding a NSArrayController to a NSPopupButtonn NSTextField

2013-02-17 Thread John Joyce

On Feb 16, 2013, at 1:21 AM, Keary Suska cocoa-...@esoteritech.com wrote:

 On Feb 15, 2013, at 5:41 AM, Eric Gorr wrote:
 
 I have a NSArrayController filled with an array of NSDictionaries.
 
 [[self controller] addObject:@{ @name : @itemA, @part : @partA }];
 [[self controller] addObject:@{ @name : @itemB, @part : @partB }];
 [[self controller] addObject:@{ @name : @itemC, @part : @partC }];
 
 I am populating a NSPopupButton with the items in this array based on the 
 'name' key. This is easily accomplished with the following bindings.
 
 Content Array binding - 
  bound to: Array Controller
  controller key: arrangedObjects
 
 Content Values binding
  bound to: array controller
  controller key: arrangedObjects
  model key path: name
 
 I would then like to populate a NSTextField with the text in the 'part' key 
 based on the current selection of the NSPopupButton. I have setup the 
 following binding:
 
 Value binding
  bound to: array controller
  controller key: selection
  model key path: part
 
 With these bindings alone, the text field does display 'partC'.
 
 However, if I change the value of the NSPopupMenu, what the text field shows 
 does not change.
 
 It is useful to note that even though an object will bind to an 
 NSArrayController, it does not mean that it will employ the controller's 
 selection semantics. NSPopupButton is one of them, I believe. The proper 
 way to do this is bind the NSPopupButton's selectedObject/Value to a 
 controller that maintains the value (*not* the array controller), and then 
 bind the NSTextField to that other controller. You may be able to use an 
 NSObjectController in the xib to act as the proxy for the value, however 
 kludgey.
 
 HTH,
 
 Keary Suska
 Esoteritech, Inc.
 Demystifying technology for your home or business
 

On the contrary, this totally can work.

Here's how… (a tutorialized version of the OP's originally linked test app with 
corrections)

Binding NSArrayController to NSPopUpButton

In your AppDelegate.h file, add a property for an NSArray.

@property (strong) NSArray *anArray;

In the AppDelegate.m file, in the applicationDidFinishLaunching: method, create 
an NSArray of NSDictionary objects.
(using NSArray and NSDictionary literals here for convenience)

_anArray = @[ @{@aKey : @Value for aKey, @anotherKey in dict1 : @Value 
for anotherKey in dict1},
@{@aKey : @Value for aKey, 
@anotherKey in dict2 : @Value for anotherKey in dict2},
@{@aKey : @Value for aKey, 
@anotherKey in dict3 : @Value for anotherKey in dict3},
@{@aKey : @Value for aKey, 
@anotherKey in dict4 : @Value for anotherKey in dict4}];

In xib file, add one NSPopUpButton, one NSTextField label and one 
NSArrayController.

The NSArrayController Bindings
Select the NSArrayController object in the xib, then select the Bindings 
Inspector.
In the Bindings Inspector, click on Content Array.
For Bind to, select App Delegate from the popupbutton menu.
For the field Model Key Path , enter self.anArray to bind the NSArrayController 
to the NSArray anArray in the AppDelegate.

The NSPopUpButton Bindings
Select the NSPopUpButton object in the xib, then select the Bindings Inspector.
In the Bindings Inspector, click on Content .
For Bind to, select Array Controller from the Bind to PopUpButton menu.
For the field Controller Key , enter arrangedObjects.
This sets the data source, if you will, for the NSPopUpButton in your xib.

In the Bindings Inspector, click on Content Values .
For Bind to, select Array Controller from the Bind to PopUpButton menu.
For the field Controler Key , enter arrangedObjects.
For the Model Key Path, enter the key name for the values from your 
dictionaries that you want to display in your NSPopUpButton menu.
In this case, enter aKey.
This determines what values from your data source objects are displayed in your 
NSPopUpButton menu.

In the Bindings Inspector, click on Selected Index .
For Bind to, select Array Controller from the Bind to PopUpButton menu.
For the field Controler Key , enter selectionIndex.
This will update the Array Controller's property selectionIndex to the index of 
the object selected in the NSPopUpButton.

The NSTextField Bindings
Select the NSTextField object in the xib, then select the Bindings Inspector.
In the Bindings Inspector, click on Value.
For Bind to, select Array Controller from the Bind to PopUpButton menu.
For the field Controler Key , enter selection.
For the Model Key Path, enter the key name for the values from your 
dictionaries that you want to display in your NSTextField.
In this case, enter anotherKey.
This will display the value for anotherKey from the dictionary object that is 
selected in the NSPopUpButton.

Save, build and run.

Clicking the NSPopUpButton will display the value for the 

Re: Binding a NSArrayController to a NSPopupButtonn NSTextField

2013-02-17 Thread Keary Suska
On Feb 17, 2013, at 8:24 AM, John Joyce wrote:

 In the Bindings Inspector, click on Selected Index .
 For Bind to, select Array Controller from the Bind to PopUpButton menu.
 For the field Controler Key , enter selectionIndex.
 This will update the Array Controller's property selectionIndex to the index 
 of the object selected in the NSPopUpButton.

This is really the key here--what I forgot is that NSTableView automatically 
binds selectedIndex behind the scenes, which is why selection semantics just 
seem to work. For others, selectionIndex wants to be explicitly bound.

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business


___

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

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


Re: what does the return value for textFieldShouldReturn actually do???

2013-02-17 Thread Matt Neuburg
On Tue, 01 Jan 2013 20:15:00 +0800, Roland King r...@rols.org said:
I have a UITextField with a delegate. I implement textFieldShouldReturn: and 
that returns a BOOL value. The docs say this about the return value

YES if the text field should implement its default behavior for the return 
button; otherwise, NO.

I've never seen any difference in behaviour between returning YES or NO. What 
is this default behaviour I'm asking it to do, or not do? 

It has to do with the Did End on Exit control event; this event, if hooked up, 
causes the keyboard to be dismissed when the user taps the Return button, 
*unless* textFieldShouldReturn: stops it by returning NO. That is why, as my 
book explains, the best way to get automatic dismissal of the keyboard is to 
hook up Did End on Exit (possibly nil-targeted and uncaught) and either return 
YES from textFieldShouldReturn: or don't implement it at all. You can get 
automatic keyboard dismissal with *no code* this way.

http://www.apeth.com/iOSBook/ch23.html#_uitextfield

m.

--
matt neuburg, phd = m...@tidbits.com, http://www.apeth.net/matt/
A fool + a tool + an autorelease pool = cool!
Programming iOS 5! http://shop.oreilly.com/product/0636920023562.do
___

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

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


Re: Core Foundation Objects and Properties when using ARC

2013-02-17 Thread Matt Neuburg
On Fri, 11 Jan 2013 10:03:33 -0800, John McCall rjmcc...@apple.com said:
On Jan 10, 2013, at 4:35 PM, Dave d...@looktowindward.com wrote:
 I've looked all over and just can't seem to find the recommended approach to 
 handling CF objects in properties when using ARC.
 
 I have an init method that needs to create a CF object and store it as a 
 property for use while the object is alive. When the object is released I 
 want to release the CF Object,
 
 Code:
 
 -(id) init
 {
 // normal init code
 
 
 CFThingRef myCFThing = CFThingCreate();
 
 self.propCFThing = myCFThing;
 }
 
 
 -(void) dealloc
 {
 CFRelease(self.propCFThing);
 self.propCFThing = NULL;
 }
 
 This code gives analyzer warnings saying that a CF object has leaked.
 
 What is the best way to stop the warnings?

This isn't really about ARC.  ARC doesn't currently manage objects of CF type.

If the property is really readonly except for initialization, the best pattern 
is to (1) mark the property readonly and (2) assign directly to the ivar in 
the -init method.  Don't forget to also (3) release the ivar in -dealloc.

I would just add: test your ivar for NULL before CFReleasing it. CFReleasing 
NULL will crash your code. Been there done that!

Example of a setter (hmm, maybe I should be testing first to make sure that 
_bitmapContext and bitmap aren't the same object):

if (self-_bitmapContext)
 CGContextRelease(self-_bitmapContext);
self-_bitmapContext = bitmap;

Example of dealloc:

- (void) dealloc {
if (_bitmapContext)
CGContextRelease(_bitmapContext);
}

m.

--
matt neuburg, phd = m...@tidbits.com, http://www.apeth.net/matt/
A fool + a tool + an autorelease pool = cool!
Programming iOS 5! http://shop.oreilly.com/product/0636920023562.do
___

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

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


Re: Tracking object references

2013-02-17 Thread Matt Neuburg
On Sat, 12 Jan 2013 11:13:13 +, Mike Abdullah cocoa...@mikeabdullah.net 
said:

The allocations instrument can show you all presently allocated objects. Find 
the object(s) you're interested in from that list and you can view its history 
of being retained and (auto)released, to figure out what is still holding onto 
it.

Actually, Instruments is no help in figuring out what is still holding onto 
it. That's not entirely unreasonable, since in a very real sense *no* object 
is holding onto anything; there are only messages and the object's own 
internal retain count. But it sure would be nice if Instruments did give more 
info about this, so that one could try to track down which retains are balanced 
by which releases (and which retains, therefore, are unbalanced). A mere retain 
count over time, along with a call stack, just doesn't quite cut it somehow. m.

--
matt neuburg, phd = m...@tidbits.com, http://www.apeth.net/matt/
A fool + a tool + an autorelease pool = cool!
Programming iOS 5! http://shop.oreilly.com/product/0636920023562.do
___

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

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


Re: Tracking object references

2013-02-17 Thread Ken Thomases
On Feb 17, 2013, at 11:50 AM, Matt Neuburg wrote:

 On Sat, 12 Jan 2013 11:13:13 +, Mike Abdullah cocoa...@mikeabdullah.net 
 said:
 
 The allocations instrument can show you all presently allocated objects. 
 Find the object(s) you're interested in from that list and you can view its 
 history of being retained and (auto)released, to figure out what is still 
 holding onto it.
 
 Actually, Instruments is no help in figuring out what is still holding onto 
 it. That's not entirely unreasonable, since in a very real sense *no* object 
 is holding onto anything; there are only messages and the object's own 
 internal retain count.

Well, you can't figure out what object is holding onto another object, but you 
can figure out which _body of code_ is holding onto an object.

 But it sure would be nice if Instruments did give more info about this, so 
 that one could try to track down which retains are balanced by which releases 
 (and which retains, therefore, are unbalanced).

Well, Instruments can no more divine which release balances which retain as it 
can know what object might hold what other object.

 A mere retain count over time, along with a call stack, just doesn't quite 
 cut it somehow.

Well, you have to analyze the retain/release history yourself, but all of the 
necessary information is there.

What I would appreciate is a GUI to assist the developer in keeping track of 
what his analysis determines.  For example, dragging releases in the history 
onto retains in the history to match them up, visually showing both that those 
retains and releases are presumed to be balanced and, when requested, showing 
the link between them.  For example, balanced retains and releases could be 
dimmed or struck through.  Eventually, only the unbalanced retains would stand 
out.

Regards,
Ken


___

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

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


Re: iOS 6.0 SDK UIApplicationInvalidInterfaceOrientation

2013-02-17 Thread Matt Neuburg
On Mon, 04 Feb 2013 00:36:28 -0500, Mazzaroth M. taomaili...@gmail.com said:
I am getting this error in a universal iOS 6.0 sdk app:
[snip]
2)_playerVC is a MPMoviePlayerViewController subclass

My advice: Use MPMoviePlayerController instead, make your own view controller, 
don't worry, be happy. More work, but you are in control. 
MPMoviePlayerViewController sucks; I have a wonderful proof of this, but the 
margin is too small to hold it. m.

--
matt neuburg, phd = m...@tidbits.com, http://www.apeth.net/matt/
A fool + a tool + an autorelease pool = cool!
Programming iOS 5! http://shop.oreilly.com/product/0636920023562.do
___

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

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


Tracking visibleRect changes using Autolayout

2013-02-17 Thread iain
Hello,

I have a very wide view which is placed inside an NSScrollView using
Autolayouts. The view's horizontal intrinsic width is the width of the
view, and the intrinsic height is NSViewNoIntrinsicMetric because I want it
to be whatever height the parent gives it. To do this, I've set the
constraints on the NSClipView parent to V:|[my_view]| This is all working
fine so far.

The background of the view is a relatively complicated drawing operation,
and I'd like to cache the visibleRect portion of the drawing, so that I can
just blit it to the screen and then draw over the top. My problem is I
can't work out how to track when visibleRect changes. Before switching to
Autolayout I was overriding -[NSView resizeWithOldSuperviewSize:], and then
creating a new cache with the visibleRect size in that, but the presence of
resizeWithOldSuperviewSize: appears to stop Autolayout from working.

Does anyone have any hints of something I may have missed, or something I'm
going about the wrong way?

Thanks,
iain
___

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

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


IOS iPad PopOver Nav bar color

2013-02-17 Thread Trygve Inda
I have a popover view and would like a nav-like title bar on it in a dark
color that matches the frame gradient of the popover fram. I can make the
nav bar grey or black, but can't seem to get it to apply the gradient that
the frame has.

Ical seems to be able to do this when you tap Calendars in the upper
right, the title Show Calendars is on a title bar that I would like.

Thanks,

Trygve



___

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

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


Re: NSDrawer not always sending -drawerDidOpen: to delegate

2013-02-17 Thread Jerry Krinock
OK, so while the drawer was in the broken state again, with the delegate wired 
in the nib, I poked it with the debugger again and found that, in order to fix 
it, I must first set the drawer's delegate to nil before setting it back to the 
window controller.  That is, this did not work:

(lldb) expr (void)[$1 setDelegate:$4] 

but this did:

(lldb) expr (void)[$1 setDelegate:nil] ;  (void)[$1 setDelegate:$4] 

Then, without doing anything to fix it but leaving the delegate wired up in the 
nib only, I scripted the app to launch 500 times with some random delays to 
open the window and the troublesome drawer and ran the script overnight.  
Result: all 500 good.  Then I added a new fix, which is to do the But this 
did above, in code, 1.0 seconds after -awakeFromNib, and that passed 100 times.

So I've applied two credible fixes for this non-reproducible problem.  I hope 
it's fixed; need to move on.  Thanks again, Kyle.


___

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

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


Re: Tracking visibleRect changes using Autolayout

2013-02-17 Thread Kyle Sluder
On Sun, Feb 17, 2013, at 05:12 PM, iain wrote:
 
 Does anyone have any hints of something I may have missed, or something
 I'm
 going about the wrong way?

Unless there's something you haven't told us, you shouldn't need to keep
track of your visible rect at all.

It sounds like you're trying to be really smart and only cache the
drawing necessary for your visible rect rather than the more naive
approach of drawing a cache for your entire view whenever its bounds
change. Is this really a performance boost for you? You say that the
drawing is complicated; if by this you mean that you spend a lot of time
doing things other than blitting pixels, you are doing yourself a
disservice by drawing minimally. It would be faster for you to cache the
entire view at once.

If it really is an advantage for you to cache only the pixels that are
going to be in your visible rect, you can override -viewWillDraw to call
-getRectsBeingDrawn:… and be super-smart about your caching.

But I suggest you do some profiling and see whether you gain time by
overriding -setFrameSize: to set a flag that you pick up in an override
of -viewWillDraw to render a cache for the entire bounds of your view.

--Kyle Sluder

___

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

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

Re: Tracking visibleRect changes using Autolayout

2013-02-17 Thread iain
On Mon, Feb 18, 2013 at 6:07 PM, Kyle Sluder k...@ksluder.com wrote:

 On Sun, Feb 17, 2013, at 05:12 PM, iain wrote:
 
  Does anyone have any hints of something I may have missed, or something
  I'm
  going about the wrong way?

 Unless there's something you haven't told us, you shouldn't need to keep
 track of your visible rect at all.


It sounds like you're trying to be really smart and only cache the
 drawing necessary for your visible rect rather than the more naive
 approach of drawing a cache for your entire view whenever its bounds
 change.


Yup, that's exactly what I'm trying to do.


 Is this really a performance boost for you? You say that the
 drawing is complicated; if by this you mean that you spend a lot of time
 doing things other than blitting pixels, you are doing yourself a
 disservice by drawing minimally. It would be faster for you to cache the
 entire view at once.


I'm trying to draw a sample waveform so for some of the audio files I have
which come in around 30minutes long, even drawing to a reduction of 8192
frames/pixel you're looking at views of 10,000pixels wide (at 44100hz).
Drawing 1frame per pixel would be a view 80million pixels wide. Admittedly
that's the extreme case but drawing only the visible area is a good
performance boost, especially when I need to draw things on top of the
waveform. I do have the data points cached at certain zoom levels as well
but it's all a memory/speed trade off. I can't cache the data points at all
zoom levels, so I need to loop through the (cached) data to redraw, but
equally I can't have a pixmap backing store at each zoom level, so only
caching a pixmap of the visible area is a trade off I'm happy with.


 If it really is an advantage for you to cache only the pixels that are
 going to be in your visible rect, you can override -viewWillDraw to call
 -getRectsBeingDrawn:… and be super-smart about your caching.

 But I suggest you do some profiling and see whether you gain time by
 overriding -setFrameSize: to set a flag that you pick up in an override
 of -viewWillDraw to render a cache for the entire bounds of your view.


I'll give this a go, does -setFrameSize just deal with the visible portion
when inside an NSScrollView/NSClipView? If so, thank you, that's great.

iain holmes
___

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

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