Re: Getting bound object

2014-07-13 Thread Daniel Luis dos Santos

On 13 Jul 2014, at 21:10, Kyle Sluder k...@ksluder.com wrote:

 On Jul 13, 2014, at 11:24 AM, Daniel Santos daniel.d...@gmail.com wrote:
 
 Hello,
 
 I have a collection view in which I have subclassed the collection view item.
 In the awake from nib method I want to get the represented object but it is 
 returning nil
 
 How can I get the bound object ?
 
 You have to wait until after -awakeFromNib. Bindings aren't hooked up and 
 propagated until the entire object graph has been awoken.
 
 One option is to override -loadView to call super and then do your magic.
 
 --Kyle Sluder

I just tried that. But [self representedObject] returns nil when called in the 
subclassed NSCollectionViewItem. Any idea why ?
___

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

Setting a tag on NSProgressIndicator

2014-07-05 Thread Daniel Luis dos Santos
Hello all,

I have the item prototype of a NSCollectionView. This prototype in declared in 
a NIB file along with its view.
Now I want to display an image in this view, but while it is loading I want to 
display a circular progress indicator instead of the loaded image.

I have subclassed NSView and made it the view of the item prototype, so I can 
trigger the image loading and the replacement of the progress
indicator with the image well.

In order for the progress indicator to start animating I have to call its 
startAnimation message. But I can’t have an outlet from the progress indicator
to the item view because the NSCollectionView creates new objects for its 
items. 

So the only way I can access the subviews, is to programatically get the 
subviews. For easing that process I would like to set a tag on the progress 
indicator, but Interface builder doesn’t let me. The option appears disabled.

How can I get the progress indicator object, or any object inside the superview 
?

Thanks
___

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: IKImageBrowserCell

2014-06-11 Thread Daniel Luis dos Santos
I have been looking at NSCollectionView, and the ability to lazy load its 
elements. Some folks suggest using core data as the data source of an 
NSArrayController, that is connected to the NSCollectionView.

But, does the collection view loads its items only when they become visible ? 
From what I have gathered the array controller will have all the elements 
loaded from core data, where some of them will be faults. How do these faults 
become the collection’s objects ?




On 10 Jun 2014, at 16:20, SevenBits sevenbitst...@gmail.com wrote:

 On Tuesday, June 10, 2014, Daniel Santos daniel.d...@gmail.com wrote:
 Absolutely. What do you have in mind ?
 
 Look in the documentation. Specifically, NSCollectionView allows you to do 
 exactly what you describe; define a view, with a number of sub views, with 
 one being the image and another your button, and set them up as collection 
 view objects. I have done this and it works well.
 
 -- SevenBits
  
 
 On Monday, June 9, 2014, SevenBits sevenbitst...@gmail.com wrote:
 On Monday, June 9, 2014, Daniel Luis dos Santos daniel.d...@gmail.com wrote:
 Hello all,
 
 I have a IKImageBrowserView that I want to customise. I want to add a button 
 to each IKImageBrowser|Cell that when pushed does some action.
 
 How can I do that ?
 
 Is using NSCollectionView an option?
  
 
 Thanks
 
 
 ___
 
 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/sevenbitstech%40gmail.com
 
 This email sent to sevenbitst...@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

IKImageBrowserCell

2014-06-09 Thread Daniel Luis dos Santos
Hello all,

I have a IKImageBrowserView that I want to customise. I want to add a button to 
each IKImageBrowser|Cell that when pushed does some action.

How can I do that ?

Thanks


___

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

error details in a NSAlert

2014-04-06 Thread Daniel Luis dos Santos
Hello all,

I want to display some text indicating a list of errors the user should correct 
before submitting data.

I am using a modal NSAlert in which i set a message with a localised string 
from a table.
I want to include the error details and for that I was setting the 
informativeText field but it doesn’t show up unless its a string literal. I 
need it to be a variable value.

I also tried setting an accessory view but nothing is showed.

The code that uses the accessory view is below.

NSTextView *accessory = [[NSTextView alloc] 
initWithFrame:NSMakeRect(0,0,200,15)];
NSFont *font = [NSFont systemFontOfSize:[NSFont systemFontSize]];
NSDictionary *textAttributes = [NSDictionary dictionaryWithObject:font 
forKey:NSFontAttributeName];
[accessory insertText: informativeText];
[accessory setEditable:NO];
[accessory setDrawsBackground:NO];

NSAlert* errorAlert = [NSAlert 
alertWithMessageText:NSLocalizedStringFromTable(@The user data is not valid. 
Correct it and try again, @AccountInfoTab, @The user data is not valid. 
Correct it and try again) defaultButton:nil alternateButton:nil 
otherButton:nil informativeTextWithFormat: @];
[errorAlert setAccessoryView: accessory];
[errorAlert runModal];

InformativeText is an NSMutableString.

What I am trying to do is even possible, or am I doing anything wrong ?
___

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: error details in a NSAlert

2014-04-06 Thread Daniel Luis dos Santos
Sorry, my mistake

String was empty. Conditional that populated it failed.

On 06 Apr 2014, at 16:18, Scott Ribe scott_r...@elevated-dev.com wrote:

 On Apr 5, 2014, at 7:19 PM, Daniel Luis dos Santos daniel.d...@gmail.com 
 wrote:
 
 I want to include the error details and for that I was setting the 
 informativeText field but it doesn’t show up unless its a string literal.
 
 That's simply not true, so you're not setting up your string variable 
 correctly. Maybe it doesn't have the value you think, or maybe it's 
 over-released and the value is gone before it can be drawn.
 
 -- 
 Scott Ribe
 scott_r...@elevated-dev.com
 http://www.elevated-dev.com/
 (303) 722-0567 voice
 
 
 
 


___

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

error details in a NSAlert

2014-04-05 Thread Daniel Luis dos Santos
Hello all,

I want to display some text indicating a list of errors the user should correct 
before submitting data.

I am using a modal NSAlert in which i set a message with a localised string 
from a table.
I want to include the error details and for that I was setting the 
informativeText field but it doesn’t show up unless its a string literal. I 
need it to be a variable value.

I also tried setting an accessory view but nothing is showed.

The code that uses the accessory view is below.

NSTextView *accessory = [[NSTextView alloc] 
initWithFrame:NSMakeRect(0,0,200,15)];
NSFont *font = [NSFont systemFontOfSize:[NSFont systemFontSize]];
NSDictionary *textAttributes = [NSDictionary dictionaryWithObject:font 
forKey:NSFontAttributeName];
[accessory insertText: informativeText];
[accessory setEditable:NO];
[accessory setDrawsBackground:NO];

NSAlert* errorAlert = [NSAlert 
alertWithMessageText:NSLocalizedStringFromTable(@The user data is not valid. 
Correct it and try again, @AccountInfoTab, @The user data is not valid. 
Correct it and try again) defaultButton:nil alternateButton:nil 
otherButton:nil informativeTextWithFormat: @];
[errorAlert setAccessoryView: accessory];
[errorAlert runModal];

InformativeText is an NSMutableString.

What I am trying to do is even possible, or am I doing anything wrong ?


___

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 custom text field backspace handling

2014-03-06 Thread Daniel Luis dos Santos
I am developing a custom textfield in Cocoa. To handle the backspace character 
I should be defining :

- (void) keyUp: (NSEvent*)theEvent {
[self interpretKeyEvents: [NSArray arrayWithObject: theEvent];

NSString *text = [theEvent charactersIgnoringModifiers];
[[self text] appendString: text];
}
Then implement :

- (void) deleteBackward:(id)sender {
if ([[self text] length] == 0)
return;
NSString* textMinusLastCharacter = [[self text] substringToIndex: [[self 
text] length] - 1];
[self setText: [NSMutableString stringWithString: textMinusLastCharacter]];
[self setNeedsDisplay:YES];
}
When I run the application, for every alphanumeric character key I press I hear 
a sound. When I press the backspace key, a call is made to the deleteBackward: 
and after that the key up method appends the backspace char to the end of the 
string. How do I filter the backspace key press in a device independent manner 
(without key codes).

Seems like the event is being passed to someplace else up in the responder 
chain. How do I control that? I am avoiding comparing keyCodes that come 
through the event object. I want to remove the sound played when each character 
is pressed.


___

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

Running an NSApplication from a test case

2014-03-04 Thread Daniel Luis dos Santos
Hello all,

I have a test case where I would like to launch a UI. I have a NIB with a 
window that I load through code in the test case. Here goes the code :

- (void)testExample
{
NSArray* topLevelWidgets = nil;

NSBundle* theBundle = [NSBundle bundleForClass:[self class]];
[NSApplication sharedApplication];

Boolean nibLoaded = [theBundle loadNibNamed: @TestSetOne owner: 
[NSApplication sharedApplication] topLevelObjects: topLevelWidgets];

if (!nibLoaded)
XCTFail(@NIB file was not loaded);

[[NSApplication sharedApplication] runModalForWindow:[topLevelWidgets 
objectAtIndex:2]];
}

Problem is that the last line does not cause the window in the NIB to appear. 
If I run the code through the debugger I can see the NSWindow instance that I 
am passing to the “runModalForWindow”.

What am I doing wrong ?

Regards
___

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-using the same NIB on two owners

2011-06-26 Thread Daniel Luis dos Santos
Hello,

I have an application that has two windows. Each window is associated to a 
controller class. On one method of each class I load another NIB that has a 
subordinate window. That subordinate NIB has outlets and actions that should be 
associated to the loading class, so on the NIB I set the File's Owner to be of 
the class that loads it.

My problem is that I need to load the same NIB from two different classes, so 
the owner is different according to which class I load it from.
Is there another way to do it without the file's owner ? Subclassing the 
controller ?

Thanks for replying___

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

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


Menu item enabling

2011-06-23 Thread Daniel Luis dos Santos
Hello,

I have a submenu of the File menu that gets loaded with menu items on 
awakeFromNib().
Problem is that the method that does the menu item enabling is not being called 
on the submenu's items and so they are not enabled.

I implemented the validateUserInterfaceItem() method in a class and have set 
the target of the created menu items to that class.
It gets called for every menu item except the one with the submenu. If I expand 
the submenu it doesn't get called.
What am I missing ?

Regards
Daniel

___

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

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


Re: Menu item enabling

2011-06-23 Thread Daniel Luis dos Santos
Hello,

I thought that by implementing the validation method it wouldn't matter if the 
menu item has an action set on it. That was the problem. Once I set the action, 
the validation method started being called.

Thanks,
Daniel 

On Jun 23, 2011, at 5:42 PM, Nick Zitzmann wrote:

 
 On Jun 23, 2011, at 10:17 AM, Daniel Luis dos Santos wrote:
 
 Hello,
 
 I have a submenu of the File menu that gets loaded with menu items on 
 awakeFromNib().
 Problem is that the method that does the menu item enabling is not being 
 called on the submenu's items and so they are not enabled.
 
 I implemented the validateUserInterfaceItem() method in a class and have set 
 the target of the created menu items to that class.
 It gets called for every menu item except the one with the submenu. If I 
 expand the submenu it doesn't get called.
 What am I missing ?
 
 That message will be sent to the menu item's target if it implements 
 -validateMenuItem: or -validateUserInterfaceItem: (to be pedantic, they are 
 methods and not functions). Are you sure the target  action of the menu 
 items are being set correctly? If the action wasn't set, then they won't be 
 enabled. If the target wasn't set, and nothing in the responder chain 
 implements the action, then they won't be enabled. If the target  action 
 were set, then they should be enabled by default, but maybe the target 
 implemented one of those methods and returned NO, which would explain why 
 they're off.
 
 Also, did you ensure -autoenablesItems is turned on in the submenu? It should 
 be by default...
 
 Nick Zitzmann
 http://www.chronosnet.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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Storing bundle loaded main class instances in NSArray

2009-04-09 Thread Daniel Luis dos Santos

Summarizing the behaviour I see here

If I add an object (which is the principal class of  a bundle) to an  
NSMutableArray, later in the program I get the exception that the  
NSFileManager default manager object does not respond to a known  
message selector.
I further narrowed it down to a fread call (standard libc) that I do  
just before the exception is thrown. If I comment the fread the error  
appears at another point in the code when I am initializing a  
NSDictionary with dictionaryWithDictionary. That other error shows  
itself in the gdb log as a pointer  modified after being freed.


Since this error is a bit difficult to track and explain through  
emails, I appreciate all your help, and think I will try to debug some  
more (change the code to some other way of doing it).


Thanks anyway


On Apr 9, 2009, at 1:38 AM, Graham Cox wrote:



On 09/04/2009, at 2:13 AM, Daniel Luis dos Santos wrote:

I expect a file manager and it tells me that it does not respond to  
fileExistsAtPath



No you don't.

According to your original post, you are complaining that calling - 
addObject on _instances throws this error. So does _instances point  
to NSFileManager or an array, as the code implies?


You're confused, so the rest of us have no chance.

Regarding your comments about autorelease pools, sounds like you're  
relying on some assumed behaviour that is not stated anywhere in any  
documentation. Don't do that, you're just creating problems that  
don't need to be there. What about the autorelease pools created  
around the main event loop for example?


--Graham




___

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

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


Fwd: Storing bundle loaded main class instances in NSArray

2009-04-08 Thread Daniel Luis dos Santos

Sorry. Sent the original to another list

Begin forwarded message:


From: Daniel Luis dos Santos daniel.d...@gmail.com
Date: April 8, 2009 1:02:18 PM GMT+01:00
To: Graham Cox graham@bigpond.com
Cc: list Xcode-users xcode-us...@lists.apple.com
Subject: Re: Storing bundle loaded main class instances in NSArray

Ok, here goes,

This is were I load the bundle :

	NSString *bundlePath = (NSString*)[_configuration objectForKey:  
DRIVERBUNDLE_PATH];

NSBundle *bundle = [NSBundle bundleWithPath: bundlePath];

if (nil == bundle) {
		[errorLog addObject: [NSNumber numberWithInt:  
DRIVER_ERRORCODE_BUNDLEMISSINGATPATH]];

*logList = [NSArray arrayWithArray: errorLog];
return nil;
}

Class driverClass = [bundle principalClass];
if ((nil == driverClass) ||
		![driverClass conformsToProtocol:  
@protocol(StorageDriverInterface)]) {
		[errorLog addObject: [NSNumber numberWithInt:  
DRIVER_ERRORCODE_BUNDLEMAINCLASSNOTCOMPLIANT]];

*logList = [NSArray arrayWithArray: errorLog];
return nil;
}
_bundle = bundle;

fine until there, then later in the same method inside a loop where  
I initialize several instances of the principal class:


	id StorageDriverInterface aDriverInstance = [[driverClass alloc]  
init: driverConfig callingbackto: callback logTo:  
interfaceInitLogList];


That instantiates the object whose class was loaded.  Then in the  
same loop afterwards I want to add the previous id to an NSArray


	id saID = [_parametersOfLatestInitializedSA objectForKey:  
CONFIG_SAID];
	if ((nil != saID)  ([[saID class] isSubclassOfClass: [NSData  
class]])) {

//[_instances addObject: aDriverInstance];
[_instanceIDs addObject: saID];
[mutableInstanceDict setObject: saID forKey: CONFIG_SAID];
} else {
if (!errorOcurred) {
[errorLog addObject: [NSNumber numberWithInt: index]];
errorOcurred = YES;
}
		[errorLog addObject: [NSNumber numberWithInt:  
DRIVER_ERRORCODE_INSTANCEDIDNOTREPORTID]];

}

When I uncomment the addObject line above, later in the code  
NSFileManager throws a doesNotRespondToSelector exception, which is  
very odd.





On Apr 8, 2009, at 1:31 AM, Graham Cox wrote:



On 08/04/2009, at 10:23 AM, Daniel Luis dos Santos wrote:

The only thing I can think of, to see something like this is that  
I am probably overwriting the NSFileManager's class internal  
tables and therefore the message. When I comment out the  
assignment it all goes well.


The class that I instantiate from the bundle is handled through a  
protocol. The implementation is derived from an NSObject. I have  
considered using an NSPointerArray instead.



Show your code.

This word description is not very enlightening to anyone except  
you, who are familiar with the code.


Sounds like it could be an over-release problem, but without seeing  
the code, who knows?


--Graham






___

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

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


Re: Storing bundle loaded main class instances in NSArray

2009-04-08 Thread Daniel Luis dos Santos
Since I am using an auto release pool that is created before anything  
else, those initializers create auto released objects that will only  
be released at the end of the code execution. They will be valid until  
the program terminates




On Apr 8, 2009, at 3:01 PM, Steve Christensen wrote:

If your _instances variable is initialized using either  
[NSMutableArray array] or [NSMutableArray arrayWithCapacity:...], it  
will be autoreleased and become invalid. You can fix that by doing  
something like [NSMutableArray array] retain] or using  
[NSMutableArray alloc] initWithCapacity:...].


When an object is released, the underlying memory is reclaimed but  
any variables that were referencing the object are unmodified so  
they now point to garbage.


And as for zombies, Google is your friend. The first hit for  
NSZombieEnabled gives a good description.



On Apr 8, 2009, at 6:15 AM, Daniel Luis dos Santos wrote:

The _instances mutable array is instantiated in the default init  
method that is called on all other init methods. It is never  
released. I am using an Auto release pool. The log writes ;


2009-04-08 13:56:53.189 TestRunner[2568:813] *** -[NSFileManager  
fileExistsAtPath:]: unrecognized selector sent to instance 0x1126f0


When releasing a pointer does its value change ? or it just  
releases the memory ?

What is that zombie thing you're talking about ?


On Apr 8, 2009, at 1:53 PM, Graham Cox wrote:



On 08/04/2009, at 10:33 PM, Daniel Luis dos Santos wrote:

	if ((nil != saID)  ([[saID class] isSubclassOfClass: [NSData  
class]])) {

//[_instances addObject: aDriverInstance];

When I uncomment the addObject line above, later in the code  
NSFileManager throws a doesNotRespondToSelector exception, which  
is very odd.





Still not enough to go on.

Where is _instances initialised? Is it released anywhere? What  
does the exception log? Is it possible _instances could be being  
released leaving a stale pointer that points to NSFileManager?  
Have you run it with NSZombieEnabled turned on? Any difference?


Please post the *relevant* code.

--Graham




___

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

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


Re: Storing bundle loaded main class instances in NSArray

2009-04-08 Thread Daniel Luis dos Santos
If its outer and the code is done right, it should be disposed of when  
the code within it is no longer needed



On Apr 8, 2009, at 3:46 PM, glenn andreas wrote:



On Apr 8, 2009, at 9:34 AM, Daniel Luis dos Santos wrote:

Since I am using an auto release pool that is created before  
anything else, those initializers create auto released objects that  
will only be released at the end of the code execution. They will  
be valid until the program terminates




That's not what the memory management rules tell you to do.

How do you know that there isn't an auto-release pool outside of  
that which gets cleaned up (and nested auto release pools are  
automatically cleaned up when the outer one is)?



Glenn Andreas  gandr...@gandreas.com
http://www.gandreas.com/ wicked fun!
Mad, Bad, and Dangerous to Know



___

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

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


Re: Storing bundle loaded main class instances in NSArray

2009-04-08 Thread Daniel Luis dos Santos
I just discovered that if I don't load the code through a bundle and  
link it directly to the executable the error goes away. From the  
bundle loading code I posted at the beginning of this thread, am I  
doing anything wrong ?




On Apr 8, 2009, at 4:34 PM, Bill Bumgarner wrote:


On Apr 8, 2009, at 7:55 AM, Daniel Luis dos Santos wrote:
If its outer and the code is done right, it should be disposed of  
when the code within it is no longer needed


That still isn't correct according to the Cocoa memory management  
guidelines.   Thus, the general conclusion will be that something is  
over-released and something else subsequently receives messages  
destined for the over-released object.


A terribly common error, actually -- quite typical.

And this statement:

When I uncomment the addObject line above, later in the code  
NSFileManager throws a doesNotRespondToSelector exception, which is  
very odd.


Backs up that assessment.

So... fix your memory management to be in line with the guidelines  
*then* try and debug the problem.   Of course, fixing the memory  
management might just make the problem go away entirely.


Since this appears to be relatively new code, one possible fix would  
be to simply turn on GC.  If it is a command line tool -- or a  
daemon -- read the docs on how to start the collector thread.


b.bum



___

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

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


Re: Storing bundle loaded main class instances in NSArray

2009-04-08 Thread Daniel Luis dos Santos
I expect a file manager and it tells me that it does not respond to  
fileExistsAtPath



On Apr 8, 2009, at 5:05 PM, Bill Bumgarner wrote:


On Apr 8, 2009, at 8:48 AM, Daniel Luis dos Santos wrote:
I just discovered that if I don't load the code through a bundle  
and link it directly to the executable the error goes away. From  
the bundle loading code I posted at the beginning of this thread,  
am I doing anything wrong ?


Doesn't look like it, but I'd focus -- instead -- on the original  
bug.   Run with Zombies enabled.  Figure out why you end up with a  
File Manager reference where you expect an array reference.


b.bum



___

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

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


Storing bundle loaded main class instances in NSArray

2009-04-07 Thread Daniel Luis dos Santos

Hello,

I have some code that loads a bundle like :

[NSBundle bundleForPath: path]

Then I get its main class. Then I cycle through some parameters that  
initialize that loaded main class and stores each new instance in a  
NSMutableArray.


Problem is that when I do the assignment to the array that causes the  
code later to behave unstable and failing with a message like :


2009-04-08 01:03:48.357 TestRunner[9643:813] *** -[NSFileManager  
fileExistsAtPath:]: unrecognized selector sent to instance 0x1126f0


The only thing I can think of, to see something like this is that I am  
probably overwriting the NSFileManager's class internal tables and  
therefore the message. When I comment out the assignment it all goes  
well.


The class that I instantiate from the bundle is handled through a  
protocol. The implementation is derived from an NSObject. I have  
considered using an NSPointerArray instead.


Help!


___

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

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


memory deallocation

2009-04-04 Thread Daniel Luis dos Santos

Hello,

From what I know so far, memory allocated using the malloc() family  
of functions is freed using the free() function. Literal values such  
as :


char *aString = some text;

are automatic values and are deallocated by the compiler automatically.

When I free some pointer that was allocated as in the example  
declaration above I get a warning that a non page-aligned, non  
allocated pointer is being freed. Then in practical terms, what does a  
literal value such as a #define that is used to initialize pointers  
such as the one above serves for ?


If for example I have a group of string #defines that are used in log  
messages, that means that I will have to malloc space for them the  
sprintf them to it, so I can be sure that I don't get that warning  
when deallocating the log messages.


when you pass as pointer to bytes (like a void*) to cocoa (for example  
NSData), what does it do ? It copies the bytes or just copies the  
pointer ? If I pass aString to it that means that at the end of the  
scope it will be deallocated, and NSData will have a dangling pointer ?

___

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

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


Memory allocation pattern related question

2009-03-29 Thread Daniel Luis dos Santos

Hello,

I have a shared library and some client code. In the shared library I  
am adopting the following method signature pattern :


- (int) someMethod: (aType*)someInParam anotherParam:  
(aType**)someOutParam;


I use the return value to indicate success or failure in the execution  
of the method, and the arguments to pass parameters in and out.

The out parameters are double pointers.

Also, the pattern I am using mandates that the out parameters  
dereferenced values are allocated within the method. So :


- (int) someMethod: (aType*)someInParam anotherParam:  
(aType**)someOutParam {


*aType = [[aType alloc] init];

return 0;
}

would do some logic and allocate the return value and set it to the  
double pointer, that would be the visible on the calling scope.


My problem is that I am not really sure of the way Cocoa retains and  
releases objects.
Using a global auto release-pool, when is the out param object  
released ? At the end of the scope of someMethod ? or when I  
explicitly release it ?
If the former, I have to retain it withing some method so that when  
its scope finishes the ref count doesn't go to zero right ?


Since the idea is to continue using the return type throughout the  
enclosing method call's scope how do I implement this safely so that I  
don't end up trying to access release memory ?


Thanks

___

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

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


NSTimer EXC_BAD_ACCESS

2008-12-13 Thread Daniel Luis dos Santos

Hello,

I have a NSTimer that is created every time I press a button. It then  
calls the update function successively until some amount of time passes.
When I press the button again I get a EXC_BAD_ACCESS on the timer's  
initialization :


	NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval: step  
target: self

selector: @selector(_updateDisplay:) userInfo: nil repeats: 
YES];

step is a double, and _updateDisplay has the right signature.
The stack trace is something like :

#0  0x90705558 in tiny_malloc_from_free_list
#1  0x906fe3ed in szone_malloc
#2  0x906fe2f8 in malloc_zone_malloc
#3  0x932b9451 in _CFRuntimeCreateInstance
#4  0x9327f844 in CFDateCreate
#5	0x93329f63 in -[__NSPlaceholderDate  
initWithTimeIntervalSinceReferenceDate:]

#6  0x9332a7fd in +[NSDate dateWithTimeIntervalSinceNow:]
#7	0x9034aa3f in +[NSTimer(NSTimer)  
scheduledTimerWithTimeInterval:target:selector:userInfo:repeats:]


I haven't any idea,...

___

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

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


Symbol not found error

2008-12-09 Thread Daniel Luis dos Santos

Hello,

I am getting this error  over and over again, whenever I do a new  
target in some place and then try to use it somewhere else.
I have a dynamic library in a project that is used in another project.  
Then I added another dynamic library to the first one which is also  
used by the second project.


The first lib links and the last won't link. The symbols are not  
found. From the gcc command line the -L option is the same because the  
dylib is in the same directory, a new -llibname flag is added for  
the new dylib (I dragged the lib file from the finder to the xcode  
tree).

When I do an nm on the lib file, the symbols are there.
I changed the install name to have the rpath, but is only relevant at  
run-time, right?


Can't find out why this happens
___

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

This email sent to [EMAIL PROTECTED]


Time measurement

2008-12-01 Thread Daniel Luis dos Santos

Hello,

Not sure I should ask this here.

How do I get time measurements in milliseconds? What is the accuracy  
of the mac's C library implementation ?


I am using the clock() function from time.h and measuring differences  
in seconds between the trigering of a NSTimer.


The NSTimer fires every 0.1 secs, and in the event code I measure the  
difference between the current clock() call and the previous. I then  
divide it by the CLOCKS_PER_SEC constant and get two orders of  
magnitude difference than the interval in the timer. I get 0.001 secs  
instead of the 0.1 of the NSTimer.


Any ideias ?

___

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

This email sent to [EMAIL PROTECTED]


Re: NSTimer issue

2008-11-06 Thread Daniel Luis dos Santos



You already answered your own question. If you see two different  
values for 'self' for two objects of your view subclass then of  
course there are two instances.




The NIB file has a window taken from the pallete, where I have dropped  
a button and a generic NSView both from the pallete. On the NSView's  
properties I have changed the class name from NSView to a class in my  
Xcode project. I also have an NSObject item taken from the pallete  
which represents the same object implementing the view.


This situation usually comes about when a view is created in code,  
and a view of the same class is also added to a NIB file.


Note that, because the view you're actually controlling via the  
timer (presumably the one created in code) doesn't draw, it probably  
hasn't been added to a superview either. It sounds like you  
accidentally created a new view instead of getting a reference to  
the one in the NIB file using an IBOutlet.



Now it is obvious that the view in the window and the object in the  
xib are not the same.


___

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

This email sent to [EMAIL PROTECTED]


NSTimer issue

2008-11-05 Thread Daniel Luis dos Santos

Hello,

I have an NSView derived class where I have to do some drawing inside  
NSRect.


When pressing a start button, a timer is created with :

+ (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)seconds  
target:(id)targetselector:(SEL)aSelector userInfo:(id)userInfo repeats: 
(BOOL)repeats


In the target argument I pass self, and as selector a method of the  
class in question. When update is called, the self object has the  
address I passed when creating the timer. Inside the method I call  
setNeedsDisplay: so the drawRect method is called in the event loop.


That call never happens and only when I force the redrawing of the  
view through dragging or overlapping windows, the drawRect is called  
but with a different address on self.


I don't understand what is happening. Are there two instances ?


___

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

This email sent to [EMAIL PROTECTED]


Path handling routines

2008-10-29 Thread Daniel Luis dos Santos

Hello,

Are there in the Foundation framework (or anywhere else on the Cocoa  
platform) path handling routines (directory extraction, path  
decomposition) ?


Cheers
___

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

This email sent to [EMAIL PROTECTED]


sizeof(unsigned long long)

2008-09-27 Thread Daniel Luis dos Santos

Hello,

I have a piece of C code that generates an unsigned long long from an  
sequence of unsigned char's.


When I do sizeof(unsigned long long) i get 8.
Afterwards I try to shift each unsigned char into its position along  
the destination unsigned long long variable, but I get a warning from  
the compiler that I am shifting beyond the type's capacity. That is  
not surprising since I am targeting 32 bit.
Then I don't understand why the size of returns 8. Shouldn't it return  
4 ?


I'm running Xcode 3.0 on Leopard.
___

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

This email sent to [EMAIL PROTECTED]


How to call functions of a C dylib on a C++ dylib

2008-09-18 Thread Daniel Luis dos Santos
I am having trouble getting it to compile. From what I understand  
there must be an extern C before the inclusion of the C lib's header  
files.

I still get a link error. Is there anything else to it ?
___

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

This email sent to [EMAIL PROTECTED]


Re: How to call functions of a C dylib on a C++ dylib

2008-09-18 Thread Daniel Luis dos Santos
Sorry, I forgot to say that I was already doing that. And it does  
build, my problem is in the link stage.



On Sep 18, 2008, at 3:00 PM, Negm-Awad Amin wrote:



Am Do,18.09.2008 um 15:55 schrieb Daniel Luis dos Santos:

I am having trouble getting it to compile. From what I understand  
there must be an extern C before the inclusion of the C lib's  
header files.

I still get a link error. Is there anything else to it ?
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/negm-awad%40cocoading.de

This email sent to [EMAIL PROTECTED]
You have to include the headers for your source code (compiling) and  
the lib itself for linking.


Cheers

Amin Negm-Awad
[EMAIL PROTECTED]






___

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

This email sent to [EMAIL PROTECTED]


Re: Mixing ObjC and C++ STL on same ObjC source file

2008-09-13 Thread Daniel Luis dos Santos


On Sep 12, 2008, at 11:21 AM, Daniel Luis dos Santos wrote:

The problem was that in CVDisplayPipeline.h I was declaring the map  
as a return type of a method, but without specifying the template  
types (caused by my relative ignorance of C++).


Now I have another problem, which I wonder if you could help :

On one project I have a target that builds a shared library target  
in C++ exclusively. On another target I have a objC app that uses  
the first as a project dependency.


When I call a method on the library with a pointer to a STL map  
(std::mapstd::string, std::string) as an argument, the linker  
complains it can't find it. I made a test method on the lib that  
takes only a std::string and it works. Passing a std::mapint, int  
fails with the same error. Other methods in the lib that don't use  
STL are found by the linker.


Don't know what is happening, or if there is any limitation because  
of STL.




I looked up the documentation from apple on using the C++ runtime, and  
learned that in practice it is not to be assumed that two C++ runtime  
versions even on the same OS maintain compatibility. Then one should  
not put STL on library boundaries because of portability between  
libstdc++ implementations.


That said, STL can be used only within a library's own code. Then when  
coding a shared library one must implement all kinds of data  
structures that can be used at the boundary. Isn't that like  
reinventing the wheel ?


Having to implement those data structures is a lot of work (at least  
for who's beginning to write C code). Having to do a map  
implementation or a linked list is almost like starting from scratch.  
Is there any implementation of those standardized in the C world (that  
is only C and portable) ?


___

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

This email sent to [EMAIL PROTECTED]


Mixing ObjC and C++ STL on same ObjC source file

2008-09-12 Thread Daniel Luis dos Santos

Hello !

I have an objective C class and want to call a method on a class in C+ 
+. As argument to the C++ class is a map instance of the STL.

The ObjC class definition is on a file with a mm extension.

I have std::map *var as a member variable of the ObjC class. When I  
compile the code there is an error saying :


/Users/dlsa/code/Finema/trunk/LiquidSurfaces/src/CVDisplayPipeline.h: 
20: error: using-declaration for non-member at class scope


How do I do this ?
___

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

This email sent to [EMAIL PROTECTED]


Autorelease question

2008-03-13 Thread Daniel Luis dos Santos

Hello,

I have the following code :

if (![fileMgr fileExistsAtPath: indexFilePath]) {
NSMutableDictionary *index = [[NSMutableDictionary alloc] init];
		[index setObject: [NSNumber numberWithLong: DEFAULTS_BLOCKSIZE]  
forKey: INDEXKEY_BLOCKSIZE];
		[index setObject: [NSNumber numberWithLong: DEFAULTS_BLOCKSPERPAGE]  
forKey: INDEXKEY_BLOCKSPERPAGE];

_blockSize = DEFAULTS_BLOCKSIZE;
_blocksPerPage = DEFAULTS_BLOCKSPERPAGE;
if (![index writeToFile: indexFilePath atomically: YES]) {
_dirPath = nil;
NSLog(LOGMSG_INDEXFILENOTWRITABLE);
}
[index release];
} else {
		NSDictionary *index = [NSDictionary dictionaryWithContentsOfFile:  
indexFilePath];

if (nil == [index objectForKey: INDEXKEY_BLOCKSIZE]) {
NSLog(LOGMSG_INDEXFILEOUTOFFORMAT);
_dirPath = nil;
} else
			_blockSize = [(NSNumber*)[index objectForKey: INDEXKEY_BLOCKSIZE]  
longValue];

if (nil == [index objectForKey: INDEXKEY_BLOCKSPERPAGE]) {
NSLog(LOGMSG_INDEXFILEOUTOFFORMAT);
_dirPath = nil;
} else
			_blocksPerPage = [(NSNumber*)[index objectForKey:  
INDEXKEY_BLOCKSPERPAGE] longValue];

[index release];
}

the [index release] on the second branch gives me the following output  
on the debugger window :


TestRunnrer(1661) malloc: *** error for object 0x112a50: double free
*** set a breakpoint in malloc_error_break to debug

in the enclosing scope I have set up an autorelease pool. What I am  
suspecting is that when I init the dictionary with a file it is  
autoreleased, and then the error when I do the release. I this the  
case ? If so where do I know when some object is created autoreleased  
or not ? In the NSDictionary's reference page there is nothing  
mentioned.


Many thanks
___

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

This email sent to [EMAIL PROTECTED]