Re: allKeys and allValues

2010-10-05 Thread gMail.com
Hi Dave,
Thanks. Your solution seems to be fine

NSArray * allKeys = [dictionary allKeys];
NSArray * allValues = [dictionary objectsForKeys:allKeys
notFoundMarker:[NSNull null]];

I also took a better look at the iTunes Music Library.xml dictionary, and
there is a fine trick.
The Tracks dictionary contains, yes, several dictionaries whose keys are
IDs.
But each track dictionary contains the same ID into its values. Like

Tracks  Dictionary  4000 items
2604Dictionary  32 items
Track IDNumber  2604

This way, I can retrieve the track dictionary in a while.
And If I have the track dict only, I can always know its ID and retrieve its
position on the Tracks dictionary.
Smart.

Thanks to everybody.

--
Leo



Da: Greg Parker 
Data: Mon, 4 Oct 2010 14:40:31 -0700
A: "gMail.com" 
Cc: "cocoa-dev@lists.apple.com List" 
Oggetto: Re: allKeys and allValues

On Oct 4, 2010, at 2:31 PM, Ken Thomases wrote:
> On Oct 4, 2010, at 4:21 PM, gMail.com   wrote:
>> On the docs I read that for both the NSDictionary's allKeys and allValues,
>> the order of the elements in the array is not defined. Ok.
>> But, are the two arrays aligned each other?
> 
> If the docs don't contain that promise, then you can't rely on it.

The documentation for CFDictionaryGetKeysAndValues() does promise to return
parallel arrays, so you might be able to use that instead.


-- 
Greg Parker gpar...@apple.com Runtime Wrangler




___

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


Confused about floats

2010-10-05 Thread Amy Heavey
I've got two float values (x and y) that I'm using to change the  
coordinates of a drawing action that is being looped through. I can  
add a value to x and it draws the next image along, but I want to test  
the value of x and if it is out of bounds I want to reset it to zero  
and increase y, so I get a grid of images drawn.


For some reason, even though I can do
x = x+128;
and it moves the image accross, x seems to be null so I can't test  
against it, my if statement ' if (x > 300){' always fails.


This must be something really simple I just can't see it this morning?  
I'd appreciate any help.


Many Thanks

Amy

Full code being used:

//select all images for kit
	 NSArray* kitImages = [kit  
valueForKeyPath:@"kitItems.kitItemProduct.productImage"];


//set coordinates to x,y -> 0,0 to start
float x = 0;
float y = 0;
//for each image
NSEnumerator *imageLoop = [kitImages objectEnumerator];
NSString *imgPath;
while ((imgPath = [imageLoop nextObject])) {
NSImage *img = [[NSImage alloc]initWithContentsOfFile:imgPath];

//apply image to view
[targetImage lockFocus];
[img drawInRect:NSMakeRect(x,y,100,100)
  fromRect:NSMakeRect(x,y,100,100)
 operation:NSCompositeCopy
  fraction:1];

[targetImage unlockFocus];

//set new coordinates
x = x+100;

		//if coordinates are too wide, start new row - if x>300, reset x to  
0 and add 100 to y

if(x > 300){
x = 0;
y = y+100;
}

}

	NSBitmapImageRep *bmpImageRep = [[NSBitmapImageRep alloc]initWithData: 
[targetImage TIFFRepresentation]];


[targetImage addRepresentation:bmpImageRep];

NSData *data = [bmpImageRep representationUsingType: NSJPEGFileType

 properties: nil];
[data writeToFile: kitimagePath
   atomically: NO];
//link images to kit
[kit setValue:kitimagePath forKey:@"kitImage"];
}



___

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


FSCatalogSearch miss file

2010-10-05 Thread Robert Černý
Hello folks,
I'm using FSCatalogSearch to find files on HFS+ formatted RAID and
found that I don't have one file in the search results. There is
nothing different on the file (permissions, special characters etc).
Does anybody have an idea what could be wrong? Corrupted index?

Thanks
Robert
___

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


Partially opaque window with opaque views

2010-10-05 Thread Trygve Inda
Is there a way to have a window with a 50% opaque background, but several
odd-shaped views that are 100% opaque? The dock does this but seems be one
window per icon. Can I do it all as one window?

My NSWindow subclass looks like:

[self setOpaque:NO];
[self setHasShadow: YES];
[self setLevel:NSFloatingWindowLevel];
[self setAlphaValue:0.50];

This sets the alpha of the whole window to 50% (and works) but If I add a
line or replace the alpha line with: [[self contentView]
setAlphaValue:0.50];

Then the window is totally opaque... Even subviews in the main contentView.

Any way to do this w/o using multiple windows?

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

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


NSOutlineView multi cell type binding query

2010-10-05 Thread jonat...@mugginsoft.com
Morning

My NSOutlineView binds its NSTableColumn instances to NSTextFieldCells using 
NSValueBinding.

Some cells are required to contain NSPopUpButtonCell instances so the cell type 
is manipulated in - outlineView:dataCellForTableColumn:item:

NSPopUpButtonCell doesn't support value binding so the normal target->action 
approach is adopted to update the model.

However it appears that the binding machinery causes the NSPopUpButtonCell 
selection to be reset after the user has interacted with the control.

I therefore have to resync the NSPopUpButtonCell selection to the model in - 
outlineView:willDisplayCell:forTableColumn:item:

Is this expected behaviour using multiple NSCell subclasses or is it bug like?
Or should I try and directly bind the NSPopUpButtonCell instance in  - 
outlineView:dataCellForTableColumn:item:?

Presumable if a cell doesn't support a particular binding its state should 
remain unaltered.

Regards

Jonathan Mitchell

Developer
Mugginsoft LLP
http://www.mugginsoft.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: Partially opaque window with opaque views

2010-10-05 Thread Matt Gough
Yes, but you should leave  the window's alpha at 1.0.

Off top of my head, it goes something like this:

Create a subclass of NSView and set that class as the class for the contentView 
of the window (in IB)

Change that class's drawRect to :

- (void)drawRect:(NSRect)rect {
// Clear the drawing rect.
[[NSColor clearColor] set];
NSRectFill(rect);
}

Now any non-opague views you place within that view can decide their own alpha 
values (or draw with differing levels of alpha) as needed.

Matt

On 5 Oct 2010, at 11:25:45, Trygve Inda wrote:

> Is there a way to have a window with a 50% opaque background, but several
> odd-shaped views that are 100% opaque? The dock does this but seems be one
> window per icon. Can I do it all as one window?
> 
> My NSWindow subclass looks like:
> 
> [self setOpaque:NO];
> [self setHasShadow: YES];
> [self setLevel:NSFloatingWindowLevel];
> [self setAlphaValue:0.50];
> 
> This sets the alpha of the whole window to 50% (and works) but If I add a
> line or replace the alpha line with: [[self contentView]
> setAlphaValue:0.50];
> 
> Then the window is totally opaque... Even subviews in the main contentView.
> 
> Any way to do this w/o using multiple windows?
> 
> Trygve
> 


Trend Micro EMEA (GB) Limited, a Limited Liability Company. Registered in 
England No. 06766734. 
Registered office: Eversheds House, 70 Great Bridgewater Street, Manchester, M1 
5ES
Trend Micro (UK) Limited, a Limited Liability Company. Registered in England 
No. 3698292. 
Registered Office: Pacific House, Third Avenue, Globe Business Park, Marlow, 
Bucks, SL7 1YL 
Telephone: +44 1628 400500 Facsimile: +44 1628 400511

This communication and any accompanying files and attachments are intended only 
for the recipient to whom it is addressed. 
If you have received this communication in error, please immediately notify the 
Sender. You are further notified that any disclosure, 
copying or other distribution of this communication, including its attachments 
is strictly prohibited.
___

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


Unable to play a .mp3 file directly using QTMovie

2010-10-05 Thread Devarshi Kulshreshtha
Hi all,

I am trying to play a .mp3 file on click of a button using this code:

 NSString 

*audioFilePath=[[audioInputTextField stringValue]
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];NSURL

*audioUrl = [[NSURL

alloc] initWithString:audioFilePath];
QTMovie* soundToPlay = [[QTMovie alloc] initWithURL:audioUrl
error:nil];[soundToPlay play];


Here user is expected to enter a valid url for an audio file in text
field and then click button next to it to play, but it is not working
for me ie. no audio gets played :(

Can anyone suggest me, if I am doing anything wrong?

The sample code can be downloaded from here- http://db.tt/cDjFCZO

One of the example links which I tried was -
http://javamax.free.fr/sonorisation%20et%20radio/Linken%20Park%20-%20In%20The%20End.mp3
-- 
Thanks,

Devarshi
___

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: Confused about floats

2010-10-05 Thread Gregory Weston
Amy Heavey wrote:

> I've got two float values (x and y) that I'm using to change the  
> coordinates of a drawing action that is being looped through. I can  
> add a value to x and it draws the next image along, but I want to test  
> the value of x and if it is out of bounds I want to reset it to zero  
> and increase y, so I get a grid of images drawn.
> 
> For some reason, even though I can do
> x = x+128;
> and it moves the image accross, x seems to be null so I can't test  
> against it, my if statement ' if (x > 300){' always fails.
> 
> This must be something really simple I just can't see it this morning?  
> I'd appreciate any help.

This doesn't make a whole lot of sense. There's no such thing as a null float 
value and you shouldn't need to be saying "x seems to be" any particular value 
given that you have a debugger and can actually examine the value.

Frankly, my guess is that your problem is the second argument to the drawing 
method:

>   [img drawInRect:NSMakeRect(x,y,100,100)
> fromRect:NSMakeRect(x,y,100,100)
>operation:NSCompositeCopy
> fraction:1];

Are you sure that the interesting part of each source image is offset within 
its whole internal coordinate space by the same amount as you intend to draw it 
into the destination. Or should that second argument perhaps be replaced by a 
rectangle whose origin is at (0,0)?


___

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


Checking for nil-return

2010-10-05 Thread Remco Poelstra

Hi,

I'm cleaning up my code and I'm wondering about constructs like the next 
one:

[NSNumber numberWithUnsignedChar:i]
The documentation does not say it can return nil on failure, but does 
that mean it simply will never fail? What if there is no memory left?


Kind regards,

Remco Poelstra
___

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: Checking for nil-return

2010-10-05 Thread Dave DeLong
Then you have much bigger problems. 

Sent from my iPhone

On Oct 5, 2010, at 8:07 AM, Remco Poelstra  wrote:

> What if there is no memory left?
___

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: Checking for nil-return

2010-10-05 Thread Remco Poelstra

Op 5-10-2010 16:11, Dave DeLong schreef:

Then you have much bigger problems.


I already thought so :). But I noticed that [NSArray arrayWithCapacity] 
also never returns nil. But I can create a very large array, and I can 
make it bigger with addObjects:atIndexes: and that function returns 
void, so always succeeds. How is that possible?


Regards,

Remco Poelstra
___

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: Checking for nil-return

2010-10-05 Thread Matt Gough

On 5 Oct 2010, at 15:18:06, Remco Poelstra wrote:

> Op 5-10-2010 16:11, Dave DeLong schreef:
>> Then you have much bigger problems.
> 
> I already thought so :). But I noticed that [NSArray arrayWithCapacity] also 
> never returns nil. But I can create a very large array, and I can make it 
> bigger with addObjects:atIndexes: and that function returns void, so always 
> succeeds. How is that possible?
> 

Because it throws exceptions if anything bad happens at runtime (i.e out of 
memory, invalid parameters etc)

Google for NSException

Matt
Trend Micro EMEA (GB) Limited, a Limited Liability Company. Registered in 
England No. 06766734. 
Registered office: Eversheds House, 70 Great Bridgewater Street, Manchester, M1 
5ES
Trend Micro (UK) Limited, a Limited Liability Company. Registered in England 
No. 3698292. 
Registered Office: Pacific House, Third Avenue, Globe Business Park, Marlow, 
Bucks, SL7 1YL 
Telephone: +44 1628 400500 Facsimile: +44 1628 400511

This communication and any accompanying files and attachments are intended only 
for the recipient to whom it is addressed. 
If you have received this communication in error, please immediately notify the 
Sender. You are further notified that any disclosure, 
copying or other distribution of this communication, including its attachments 
is strictly prohibited.
___

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: Checking for nil-return

2010-10-05 Thread Remco Poelstra

Op 5-10-2010 16:23, Matt Gough schreef:


On 5 Oct 2010, at 15:18:06, Remco Poelstra wrote:


Op 5-10-2010 16:11, Dave DeLong schreef:

Then you have much bigger problems.


I already thought so :). But I noticed that [NSArray arrayWithCapacity] also 
never returns nil. But I can create a very large array, and I can make it 
bigger with addObjects:atIndexes: and that function returns void, so always 
succeeds. How is that possible?



Because it throws exceptions if anything bad happens at runtime (i.e out of 
memory, invalid parameters etc)

Google for NSException


Ah, I see. I thought exceptions were meant for programming errors.
This definitely helps in make sure my code behaves nice.

Regards,

Remco Poelstra
___

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: How to get selected text in a WebView

2010-10-05 Thread Gerriet M. Denkmann

On 5 Oct 2010, at 17:56, "Gary L. Wade"  wrote:

> Was there a problem with what dr.text or [dr toString] returned after your
> first line?

There was not  (and now that I tried it: there is not) - but there was (and is) 
a problem with the documentation:
Xcode only shows me the "DOMRange Additions Reference", which does only mention 
the additions, but not the basic stuff.
When I look into the header, I see all sort of useful things.

So: is there some documentation about DOMRange somewhere? 

Anyway, thanks very much for telling me about this.

Kind regards,

Gerriet.

> 
> On 10/04/2010 12:15 AM, "Gerriet M. Denkmann"  wrote:
> 
>> I have a Webview, and I want to do something with the selected text.
>> 
>> I tried: 
>> DOMRange *dr = [ webView selectedDOMRange ];
>> NSString *m = [ dr markupString ];
>> this contains the selected characters, but buried in lots of markup language.
>> But I just want the characters.
> 

___

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: Confused about floats

2010-10-05 Thread Shawn Bakhtiar

Also if x is a float, make sure you use the proper type cast, or values, ie  ( 
x = x + 120.00) or (x = y + (double)z , where x and y are double and z is an 
int). 

Remember int, float, double, are C types, and typecasting rules should be in 
effect.



> From: gwes...@mac.com
> Date: Tue, 5 Oct 2010 09:27:31 -0400
> To: cocoa-dev@lists.apple.com
> Subject: Re: Confused about floats
> 
> Amy Heavey wrote:
> 
> > I've got two float values (x and y) that I'm using to change the  
> > coordinates of a drawing action that is being looped through. I can  
> > add a value to x and it draws the next image along, but I want to test  
> > the value of x and if it is out of bounds I want to reset it to zero  
> > and increase y, so I get a grid of images drawn.
> > 
> > For some reason, even though I can do
> > x = x+128;
> > and it moves the image accross, x seems to be null so I can't test  
> > against it, my if statement ' if (x > 300){' always fails.
> > 
> > This must be something really simple I just can't see it this morning?  
> > I'd appreciate any help.
> 
> This doesn't make a whole lot of sense. There's no such thing as a null float 
> value and you shouldn't need to be saying "x seems to be" any particular 
> value given that you have a debugger and can actually examine the value.
> 
> Frankly, my guess is that your problem is the second argument to the drawing 
> method:
> 
> > [img drawInRect:NSMakeRect(x,y,100,100)
> >   fromRect:NSMakeRect(x,y,100,100)
> >  operation:NSCompositeCopy
> >   fraction:1];
> 
> Are you sure that the interesting part of each source image is offset within 
> its whole internal coordinate space by the same amount as you intend to draw 
> it into the destination. Or should that second argument perhaps be replaced 
> by a rectangle whose origin is at (0,0)?
> 
> 
> ___
> 
> 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/shashaness%40hotmail.com
> 
> This email sent to shashan...@hotmail.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: Confused about floats

2010-10-05 Thread Scott Ribe
On Oct 5, 2010, at 8:51 AM, Shawn Bakhtiar wrote:

> Also if x is a float, make sure you use the proper type cast, or values, ie  
> ( x = x + 120.00) or (x = y + (double)z , where x and y are double and z is 
> an int). 

That is *completely* unnecessary and pointless.

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

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


RE: Confused about floats

2010-10-05 Thread Shawn Bakhtiar


Eh?

Did you just call typecasting  "*completely* unnecessary and pointless"...

Can you please explain?

I have plenty of C code, in *.c files that would disagree with you. 

You may be correct in that in Objective-C this may no longer be an issue, as 
the compiler does your work for you, but that was not an assumption I was 
making.

> Subject: Re: Confused about floats
> From: scott_r...@killerbytes.com
> Date: Tue, 5 Oct 2010 08:56:45 -0600
> CC: cocoa-dev@lists.apple.com
> To: shashan...@hotmail.com
> 
> On Oct 5, 2010, at 8:51 AM, Shawn Bakhtiar wrote:
> 
> > Also if x is a float, make sure you use the proper type cast, or values, ie 
> >  ( x = x + 120.00) or (x = y + (double)z , where x and y are double and z 
> > is an int). 
> 
> That is *completely* unnecessary and pointless.
> 
> -- 
> 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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Confused about floats

2010-10-05 Thread Matt Neuburg
On Tue, 5 Oct 2010 10:17:31 +0100, Amy Heavey 
said:
>//select all images for kit
> NSArray* kitImages = [kit
>valueForKeyPath:@"kitItems.kitItemProduct.productImage"];
>
>//set coordinates to x,y -> 0,0 to start
>float x = 0;
>float y = 0;
>//for each image
>NSEnumerator *imageLoop = [kitImages objectEnumerator];
>NSString *imgPath;
>while ((imgPath = [imageLoop nextObject])) {

The enumerator and the call to nextObject are now unnecessary; fast
enumeration has been invented. So unless you're running on an old system
(of course, you might well be), you could say:

//for each image
for (NSString* imgPath in kitImages)


>NSImage *img = [[NSImage alloc]initWithContentsOfFile:imgPath];

That's a memory leak. You are saying "alloc" without a balancing "release".

>
>//apply image to view
>[targetImage lockFocus];
>[img drawInRect:NSMakeRect(x,y,100,100)
>  fromRect:NSMakeRect(x,y,100,100)
> operation:NSCompositeCopy
>  fraction:1];

Unlikely. As soon as you add 100 to x to and y, the fromRect value will be
a rectangle outside the image. So it will probably be blank or black or
something. You probably want the fromRect to be NSMakeRect(0,0,100,100),
i.e. the whole of the image is to be used as the source (assuming that the
image is 100 by 100).


>
>[targetImage unlockFocus];
>
>//set new coordinates
>x = x+100;
>
>//if coordinates are too wide, start new row - if x>300, reset x
>to  
>0 and add 100 to y
>if(x > 300){
>x = 0;
>y = y+100;
>}
>
>}
>
>NSBitmapImageRep *bmpImageRep = [[NSBitmapImageRep
>alloc]initWithData:
>[targetImage TIFFRepresentation]];

That's another memory leak.

m.

-- 
matt neuburg, phd = m...@tidbits.com, 
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.apeth.net/matt/default.html#applescriptthings





___

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: Confused about floats

2010-10-05 Thread Kyle Sluder
On Tue, Oct 5, 2010 at 8:16 AM, Shawn Bakhtiar  wrote:
>
>
> Eh?
>
> Did you just call typecasting  "*completely* unnecessary and pointless"...

No, he called the specific casting you were performing unnecessary and
pointless, which it is.

The arithmetic conversion rules say that the integer literals will be
promoted to the appropriate floating point type. So this is perfectly
fine and does exactly what you expect:

int main(int argc, char **argv) {
  float x = 2.5;
  x += 5;
  printf("%f\n", x); // prints "7.50"
  return 0;
}

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

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


Re: Confused about floats

2010-10-05 Thread Kyle Sluder
On Tue, Oct 5, 2010 at 8:20 AM, Kyle Sluder  wrote:
> The arithmetic conversion rules say that the integer literals will be
> promoted to the appropriate floating point type. So this is perfectly
> fine and does exactly what you expect:

P.S. The promotion doesn't only apply to literals but to other
expressions too. So your second casting example is unnecessary as
well. Compile this with -Wall -Werror to see that is is perfectly
valid C:


#include 
int main(int argc, char **argv) {
  float x = 2.5;
  int y = 5;
  x += y;
  printf("%f\n", x); // prints "7.50"
  return 0;
}

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

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


Re: Confused about floats

2010-10-05 Thread Scott Ribe
On Oct 5, 2010, at 9:16 AM, Shawn Bakhtiar wrote:

> Did you just call typecasting  "*completely* unnecessary and pointless"...

No, I called typecasting an int type to a floating type, in order to add it to 
a floating type, unnecessary and pointless.

> You may be correct in that in Objective-C this may no longer be an issue, as 
> the compiler does your work for you, but that was not an assumption I was 
> making.

It's got nothing to do with Objective-C; C has always taken care of that case. 
What exactly do you think is wrong with x = x + 100 where x is a double? 

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

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


Re: Confused about floats

2010-10-05 Thread Velocityboy
Both C and Objective-C support implicit casting for the primitive types.

float f = 100.0f;
f += 100;

will give the expected result, because the compiler will see (float) + (int) 
and cast the int to a float automatically. The conversion rules are part of the 
ANSI C standard and apply in Objective-C as well. Any modern compiler will also 
warn if you use an implicit conversion that could result in a loss of precision.
On Oct 5, 2010, at 8:16 AM, Shawn Bakhtiar wrote:

> 
> 
> Eh?
> 
> Did you just call typecasting  "*completely* unnecessary and pointless"...
> 
> Can you please explain?
> 
> I have plenty of C code, in *.c files that would disagree with you. 
> 
> You may be correct in that in Objective-C this may no longer be an issue, as 
> the compiler does your work for you, but that was not an assumption I was 
> making.
> 
>> Subject: Re: Confused about floats
>> From: scott_r...@killerbytes.com
>> Date: Tue, 5 Oct 2010 08:56:45 -0600
>> CC: cocoa-dev@lists.apple.com
>> To: shashan...@hotmail.com
>> 
>> On Oct 5, 2010, at 8:51 AM, Shawn Bakhtiar wrote:
>> 
>>> Also if x is a float, make sure you use the proper type cast, or values, ie 
>>>  ( x = x + 120.00) or (x = y + (double)z , where x and y are double and z 
>>> is an int). 
>> 
>> That is *completely* unnecessary and pointless.
>> 
>> -- 
>> 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:
> http://lists.apple.com/mailman/options/cocoa-dev/velocityboy%40rodentia.net
> 
> This email sent to velocity...@rodentia.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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Unable to play a .mp3 file directly using QTMovie

2010-10-05 Thread Nick Zitzmann

On Oct 5, 2010, at 6:23 AM, Devarshi Kulshreshtha wrote:

> I am trying to play a .mp3 file on click of a button using this code:
> 
> NSString 
> 
> *audioFilePath=[[audioInputTextField stringValue]
> stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];NSURL
> 
> *audioUrl = [[NSURL
> 
> alloc] initWithString:audioFilePath];
> QTMovie* soundToPlay = [[QTMovie alloc] initWithURL:audioUrl
> error:nil];[soundToPlay play];
> 
> 
> Here user is expected to enter a valid url for an audio file in text
> field and then click button next to it to play, but it is not working
> for me ie. no audio gets played :(
> 
> Can anyone suggest me, if I am doing anything wrong?

Are you sure the user is entering a valid URL and not a file path? If it's a 
path, then you need to use -initFileURLWithPath: and not -initWithString:, and 
the path shouldn't be percent-escape encoded.

Have you tried passing a pointer to an NSError pointer into the 
-initWithURL:error: message? The error you get back, if any, should tell you 
why it's not working.

Nick Zitzmann


___

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: Confused about floats

2010-10-05 Thread Corbin Dunn

On Oct 5, 2010, at 2:17 AM, Amy Heavey wrote:

> I've got two float values (x and y) that I'm using to change the coordinates 
> of a drawing action that is being looped through. I can add a value to x and 
> it draws the next image along, but I want to test the value of x and if it is 
> out of bounds I want to reset it to zero and increase y, so I get a grid of 
> images drawn.
> 
> For some reason, even though I can do
> x = x+128;
> and it moves the image accross, x seems to be null so I can't test against 
> it, my if statement ' if (x > 300){' always fails.
> 
> This must be something really simple I just can't see it this morning? I'd 
> appreciate any help.
> 
> Many Thanks
> 
> Amy
> 
> Full code being used:
>   
>   //select all images for kit
>NSArray* kitImages = [kit 
> valueForKeyPath:@"kitItems.kitItemProduct.productImage"];
>   
>   //set coordinates to x,y -> 0,0 to start
>   float x = 0;
>   float y = 0;
>   //for each image
>   NSEnumerator *imageLoop = [kitImages objectEnumerator];
>   NSString *imgPath;
>   while ((imgPath = [imageLoop nextObject])) {
>   NSImage *img = [[NSImage alloc]initWithContentsOfFile:imgPath];
>   
>   //apply image to view
>   [targetImage lockFocus];
>   [img drawInRect:NSMakeRect(x,y,100,100)
> fromRect:NSMakeRect(x,y,100,100)

^^ This is probably wrong --  it should be fromRect:NSMakeRect(0, 0, 
img.size.width, img.size.height)

corbin


___

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: Confused about floats

2010-10-05 Thread Shawn Bakhtiar


:*S

Yes... I see the point. Correct. 

For a constant value this is true, in the instance of x = x + 1 (which I see 
where the error was), where x is a float this makes no difference. 

However, for clarity of the OP, x = x + y where y is an int, should be typecast 
correctly as x = x + (float)y 

Personally when I am writing code, I always write as x = x + 1.0 for clarity as 
well.

Sorry for not understanding the rebuttal :*)


> Subject: Re: Confused about floats
> From: scott_r...@killerbytes.com
> Date: Tue, 5 Oct 2010 09:24:13 -0600
> CC: cocoa-dev@lists.apple.com
> To: shashan...@hotmail.com
> 
> On Oct 5, 2010, at 9:16 AM, Shawn Bakhtiar wrote:
> 
> > Did you just call typecasting  "*completely* unnecessary and pointless"...
> 
> No, I called typecasting an int type to a floating type, in order to add it 
> to a floating type, unnecessary and pointless.
> 
> > You may be correct in that in Objective-C this may no longer be an issue, 
> > as the compiler does your work for you, but that was not an assumption I 
> > was making.
> 
> It's got nothing to do with Objective-C; C has always taken care of that 
> case. What exactly do you think is wrong with x = x + 100 where x is a 
> double? 
> 
> -- 
> 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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Confused about floats

2010-10-05 Thread Amy Heavey
Thanks for all the help everyone, I'll take a look at it all, and  
release where I need to!


Many Thanks

Amy



On 5 Oct 2010, at 4:17PM, Matt Neuburg wrote:

On Tue, 5 Oct 2010 10:17:31 +0100, Amy Heavey >

said:

  //select all images for kit
   NSArray* kitImages = [kit
valueForKeyPath:@"kitItems.kitItemProduct.productImage"];

  //set coordinates to x,y -> 0,0 to start
  float x = 0;
  float y = 0;
  //for each image
  NSEnumerator *imageLoop = [kitImages objectEnumerator];
  NSString *imgPath;
  while ((imgPath = [imageLoop nextObject])) {


The enumerator and the call to nextObject are now unnecessary; fast
enumeration has been invented. So unless you're running on an old  
system

(of course, you might well be), you could say:

   //for each image
   for (NSString* imgPath in kitImages)



  NSImage *img = [[NSImage alloc]initWithContentsOfFile:imgPath];


That's a memory leak. You are saying "alloc" without a balancing  
"release".




  //apply image to view
  [targetImage lockFocus];
  [img drawInRect:NSMakeRect(x,y,100,100)
fromRect:NSMakeRect(x,y,100,100)
   operation:NSCompositeCopy
fraction:1];


Unlikely. As soon as you add 100 to x to and y, the fromRect value  
will be
a rectangle outside the image. So it will probably be blank or black  
or
something. You probably want the fromRect to be  
NSMakeRect(0,0,100,100),
i.e. the whole of the image is to be used as the source (assuming  
that the

image is 100 by 100).




  [targetImage unlockFocus];

  //set new coordinates
  x = x+100;

  //if coordinates are too wide, start new row - if x>300,  
reset x

to
0 and add 100 to y
  if(x > 300){
  x = 0;
  y = y+100;
  }

  }

  NSBitmapImageRep *bmpImageRep = [[NSBitmapImageRep
alloc]initWithData:
[targetImage TIFFRepresentation]];


That's another memory leak.

m.

--
matt neuburg, phd = m...@tidbits.com, 
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.apeth.net/matt/default.html#applescriptthings





___

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/home%40willowtreecrafts.co.uk

This email sent to h...@willowtreecrafts.co.uk


___

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: Confused about floats

2010-10-05 Thread Velocityboy
You can, but again this is just being explicit - the compiler bases promotion 
decisions on type alone, not whether or not an expression is a constant or a 
variable.

The one important thing to remember is that promotion of assignment is applied 
*after* the RHS is evaluated, i.e.

float f = 1 /  2;

is equivalent to

float f = (float)( 1 / 2 );

which is zero, since integer division is used.

In that case, it does matter, and either 1.0f / 2, or 1 / 2.0f will give the 
intended result.


On Oct 5, 2010, at 8:32 AM, Shawn Bakhtiar wrote:

> 
> 
> :*S
> 
> Yes... I see the point. Correct. 
> 
> For a constant value this is true, in the instance of x = x + 1 (which I see 
> where the error was), where x is a float this makes no difference. 
> 
> However, for clarity of the OP, x = x + y where y is an int, should be 
> typecast correctly as x = x + (float)y 
> 
> Personally when I am writing code, I always write as x = x + 1.0 for clarity 
> as well.
> 
> Sorry for not understanding the rebuttal :*)
> 
> 
>> Subject: Re: Confused about floats
>> From: scott_r...@killerbytes.com
>> Date: Tue, 5 Oct 2010 09:24:13 -0600
>> CC: cocoa-dev@lists.apple.com
>> To: shashan...@hotmail.com
>> 
>> On Oct 5, 2010, at 9:16 AM, Shawn Bakhtiar wrote:
>> 
>>> Did you just call typecasting  "*completely* unnecessary and pointless"...
>> 
>> No, I called typecasting an int type to a floating type, in order to add it 
>> to a floating type, unnecessary and pointless.
>> 
>>> You may be correct in that in Objective-C this may no longer be an issue, 
>>> as the compiler does your work for you, but that was not an assumption I 
>>> was making.
>> 
>> It's got nothing to do with Objective-C; C has always taken care of that 
>> case. What exactly do you think is wrong with x = x + 100 where x is a 
>> double? 
>> 
>> -- 
>> 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:
> http://lists.apple.com/mailman/options/cocoa-dev/velocityboy%40rodentia.net
> 
> This email sent to velocity...@rodentia.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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Confused about floats

2010-10-05 Thread Scott Ribe
On Oct 5, 2010, at 9:32 AM, Shawn Bakhtiar wrote:

> However, for clarity of the OP, x = x + y where y is an int, should be 
> typecast correctly as x = x + (float)y 

Why? The two are exactly equivalent.

Now if you want to do so as a stylistic preference, that's fine, but there's no 
"should" about it.

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

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


JDBC from Cocoa or the like

2010-10-05 Thread colors
Is there a framework, or set of APIs or samples available from Apple or others 
to do SQL server accesses?  I have looked at easyDB, but its license makes it a 
non-starter.  I have also looked at freetds, but it does not look like it is 
ready for prime time (let along particularly good in the Mac support arena).  
To make maters a little harder, I need to have it work on the iOS too.

*
Richard Collyer
iseecol...@sbcglobal.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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: JDBC from Cocoa or the like

2010-10-05 Thread Kyle Sluder
On Tue, Oct 5, 2010 at 9:03 AM, colors  wrote:
> Is there a framework, or set of APIs or samples available from Apple or 
> others to do SQL server accesses?  I have looked at easyDB, but its license 
> makes it a non-starter.  I have also looked at freetds, but it does not look 
> like it is ready for prime time (let along particularly good in the Mac 
> support arena).  To make maters a little harder, I need to have it work on 
> the iOS too.

If you didn't need it to work on iOS, you could use ODBC.

Why not adopt a classic N-tier architecture, and have a service with
which your apps can communicate rather than having them talk to the DB
directly?

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

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


Re: Checking for nil-return

2010-10-05 Thread Dave Keck
> Because it throws exceptions if anything bad happens at runtime (i.e out of 
> memory, invalid parameters etc)

If memory truly becomes exhausted (as opposed to attempting to
allocate a huge object), you'll crash due to a stack overflow since
the code path of throwing an exception allocates objects.
___

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: Checking for nil-return

2010-10-05 Thread Greg Parker
On Oct 5, 2010, at 7:07 AM, Remco Poelstra wrote:
> I'm cleaning up my code and I'm wondering about constructs like the next one:
> [NSNumber numberWithUnsignedChar:i]
> The documentation does not say it can return nil on failure, but does that 
> mean it simply will never fail? What if there is no memory left?

If you truly run out of memory, you should expect to crash.

A 32-bit process can run out of virtual address space. When that happens, 
allocations return NULL. But so much other code is allocate-or-die that the 
process is unlikely to survive long enough to do anything about the problem. 
(For example, objc_msgSend() sometimes needs to allocate memory, and it has no 
fallback if allocation fails.)

A process can also use all available RAM. You won't get NULL from allocations, 
but your process is still unlikely to survive. On Mac OS, your machine will 
start paging, and most likely the user will get frustrated enough to restart 
the machine first. On iOS, the system sends memory warnings and then starts 
killing processes to make room.


-- 
Greg Parker gpar...@apple.com Runtime Wrangler


___

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: JDBC from Cocoa or the like

2010-10-05 Thread Alex Kac
I saw this ODBC framework for iOS. Maybe that helps as well:
http://www.prlog.org/10938886-open-database-connectivity-odbc-arrives-for-apple-ipad-iphone-and-ipod-touch.html

One problem I've always had with the N-tier arch is that of customer security. 
Many companies simply won't use an app that doesn't talk directly to the 
database within their own private VPN/network.

On Oct 5, 2010, at 11:09 AM, Kyle Sluder wrote:

> On Tue, Oct 5, 2010 at 9:03 AM, colors  wrote:
>> Is there a framework, or set of APIs or samples available from Apple or 
>> others to do SQL server accesses?  I have looked at easyDB, but its license 
>> makes it a non-starter.  I have also looked at freetds, but it does not look 
>> like it is ready for prime time (let along particularly good in the Mac 
>> support arena).  To make maters a little harder, I need to have it work on 
>> the iOS too.
> 
> If you didn't need it to work on iOS, you could use ODBC.
> 
> Why not adopt a classic N-tier architecture, and have a service with
> which your apps can communicate rather than having them talk to the DB
> directly?
> 
> --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:
> http://lists.apple.com/mailman/options/cocoa-dev/alex%40webis.net
> 
> This email sent to a...@webis.net

Alex Kac - President and Founder
Web Information Solutions, Inc.

"Forgiveness is not an occasional act: it is a permanent attitude." 
-- Dr. Martin Luther King




___

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: Confused about floats

2010-10-05 Thread Amy Heavey

Got it working, Part of my issue seemed to be my logic.

300 is the bounds of my target image, and I have planned it so images  
fit inside this, so x would end up being 300. In a stupid moment, I  
set the if statement to run if x>300, which initially it wouldn't be  
as it would actually equal 300. However, I didn't spot my mistake as  
the NSLog inside the if statement appeared in the debugger so I  
thought it was running the rest of the code inside the if statement. I  
changed it to > 299 and voila it worked. I did also have to (is the  
term cast?) the 299 to a float.


I'm googling Fast Enumeration, but I'm compiling for 10.5,

So I'm left with the following which works as intended:

//select all images for kit
	 NSArray* kitImages = [kit  
valueForKeyPath:@"kitItems.kitItemProduct.productImage"];


//set coordinates to x,y -> 0,0 to start
float x = 0;
float y = 75;
//for each image
NSEnumerator *imageLoop = [kitImages objectEnumerator];
NSString *imgPath;

while ((imgPath = [imageLoop nextObject])) {
NSImage *img = [[NSImage alloc]initWithContentsOfFile:imgPath];

//apply image to view
[targetImage lockFocus];

		[img drawInRect:NSMakeRect(x,y,75,75)  
fromRect:NSMakeRect(20,20,150,150) operation:NSCompositeCopy fraction: 
1];


//set new coordinates
x = x+75;

		//if coordinates are too wide, start new row - if x>300, reset x to  
0 and add 100 to y

if( x > (float)299 ){

x = x-300;
y = y+75;
NSLog(@"x is greater than 300");

}

}
.
//cleanup
[bmpImageRep release];
[img release];
[kitLogoImg release];
[targetImage release];


Thanks for everyones 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


Re: Confused about floats

2010-10-05 Thread Scott Ribe
On Oct 5, 2010, at 11:18 AM, Amy Heavey wrote:

> I changed it to > 299 and voila it worked. I did also have to (is the term 
> cast?) the 299 to a float.

Yes, the term is "cast". 

No you didn't need to cast 299 to a float. It's not wrong to do so, just 
unnecessary. (And, if you care, you could instead just write 299.0, or 299f, or 
299.0f.) 

You could also just use if( x >= 300 ).

If you were using fractional pixels anywhere, you'd want x = 0 instead of x = 
x-300, so that rounding errors would not accumulate.


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

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


Re: Confused about floats

2010-10-05 Thread Matt Neuburg
On 10/5/10 10:18 AM, thus spake "Amy Heavey" :

>I'm googling Fast Enumeration, but I'm compiling for 10.5,
>
>

Fast enumeration is present in 10.5. m.

-- 
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
AppleScript: the Definitive Guide, 2nd edition
http://www.tidbits.com/matt/default.html#applescriptthings
Take Control of Exploring & Customizing Snow Leopard
http://tinyurl.com/kufyy8
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.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


Disable NSSavePanel's New Folder button dynamically?

2010-10-05 Thread Kevin Wojniak
I'm assuming the answer is no, as I've looked over the documentation, but just 
incase I missed something: is there a way to prevent NSSavePanel's "New Folder" 
button from being enabled on the fly?

For certain volumes, I don't want them to be chosen (which I can already do), 
but I also don't want New Folder to be enabled.

I attempted to try handling panel:directoryDidChange: and then calling 
setCanChooseDirectories:NO but that has no effect.

I think the best way to handle this using public APIs is to just detect the 
selected directory, and use setDirectory: to change it to something else 
(possibly showing an alert).

Any alternative advice would be appreciated.

Kevin

___

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: Disable NSSavePanel's New Folder button dynamically?

2010-10-05 Thread Sherm Pendley
On Tue, Oct 5, 2010 at 2:17 PM, Kevin Wojniak  wrote:
> I'm assuming the answer is no, as I've looked over the documentation, but 
> just incase I missed something: is there a way to prevent NSSavePanel's "New 
> Folder" button from being enabled on the fly?

[thePanel setCanCreateDirectories:NO];

sherm--

-- 
Cocoa programming in Perl:
http://camelbones.sourceforge.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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Disable NSSavePanel's New Folder button dynamically?

2010-10-05 Thread Kevin Wojniak
You know, I thought I was using that method all this time, but it seems I was 
using setCanChooseDirectories: instead, and even my email indicated that.

It's been a long morning ;-)

Thanks.


On Oct 5, 2010, at 11:35 AM, Sherm Pendley wrote:

> On Tue, Oct 5, 2010 at 2:17 PM, Kevin Wojniak  wrote:
>> I'm assuming the answer is no, as I've looked over the documentation, but 
>> just incase I missed something: is there a way to prevent NSSavePanel's "New 
>> Folder" button from being enabled on the fly?
> 
> [thePanel setCanCreateDirectories:NO];
> 
> sherm--
> 
> -- 
> Cocoa programming in Perl:
> http://camelbones.sourceforge.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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Problem with MakeKeyandOrderFront

2010-10-05 Thread Amy Heavey
My app has a secondary view that appears when I click a button (to do  
another task) it works fine most of the time. It's a core data app  
that uses an xml file store.


I've started adding data so there's now maybe 1000 instances of an  
entity in it, and I've not started adding other entities or  
relationships. My secondary view won't appear now. basically I have a  
products list that is in the first tab of a tabbed display, and then  
when I'm in the second tab the button is there to display the extra  
window with the same product list, plus other things.


Now when I click the button the focus goes from the main window but  
the second window doesn't appear. If I move the data file it works  
fine. Have I just overloaded it already? Even if all I do is open the  
app and go to the second tab and click the button, nothing?


Other than this i think I've got it doing what I want!

Thanks

Amy
___

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: Instantly delete a directory without recursion?

2010-10-05 Thread Michael Watson
You should /always/ perform I/O on a secondary thread whenever possible. Every 
I/O you perform on the UI thread is an opportunity for hangs or 
unresponsiveness. Grand Central Dispatch is your friend here.


--
michael

On 04 Oct, 2010, at 05:54, Guillem Palou wrote:

> I don't think so,
> 
> If time is a constraint, try running the delete process in a background 
> thread, if it is not a problem.
> 
> On Oct 4, 2010, at 10:24 AM, Oleg Krupnov wrote:
> 
>> Hi Guillem,
>> 
>> You are correct, in many cases the number of files will not be big, so
>> it should not matter too much, but using the opportunity, I decided to
>> illuminate myself regarding the possibilities there are in the file
>> system.
>> 
>> I had an idea that because the directory tree is growing from a single
>> root, there *might* be a possibility to axe it off with a single hit.
>> Is it possible?
>> 
>> Thanks.
>> 
>> On Mon, Oct 4, 2010 at 11:18 AM, Guillem Palou  
>> wrote:
>>> When removing directories, the OS should remove all the tree created in the 
>>> filesystem. I think you cannot do anything else?
>>> Is it so critical? How many files do you have to delete?
>>> 
>>> On Oct 4, 2010, at 10:12 AM, Oleg Krupnov wrote:
>>> 
 Let me make the question more clear: I am aware of functions like
 [NSFileManager removeItemAtPath: error:], but what they do under the
 hood is they iterate through the subdirectories and files and delete
 them first. This takes some time. I am interested if it is possible to
 do this instantly, without even implicit recursion. Just remove the
 directory and the files and subdirectories would disappear?
 
 Thanks!
 
 On Mon, Oct 4, 2010 at 11:03 AM, Oleg Krupnov  
 wrote:
> Hi,
> 
> Is there a way to delete a directory instantly and completely without
> first deleting all its subdirectories and files recursively?
> 
> Thanks.
> 
> Oleg.
> 
 ___
 
 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/guillem.palou%40gmail.com
 
 This email sent to guillem.pa...@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:
> http://lists.apple.com/mailman/options/cocoa-dev/mikey-san%40bungie.org
> 
> This email sent to mikey-...@bungie.org

___

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: Problem with MakeKeyandOrderFront

2010-10-05 Thread Ken Thomases
On Oct 5, 2010, at 1:55 PM, Amy Heavey wrote:

> Now when I click the button the focus goes from the main window but the 
> second window doesn't appear. If I move the data file it works fine. Have I 
> just overloaded it already? Even if all I do is open the app and go to the 
> second tab and click the button, nothing?

Check the console log (either in Xcode's console window or the main console log 
viewable with Console.app, depending on how you ran your app).  I bet you're 
getting an exception, which is just prematurely terminating some operation 
within your app.

If you're running in the debugger, enable breakpoints and "Stop on Objective-C 
Exceptions" in Xcode's Run menu.

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

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


Re: Instantly delete a directory without recursion?

2010-10-05 Thread Shawn Erickson
On Tue, Oct 5, 2010 at 12:48 PM, Michael Watson  wrote:
> You should /always/ perform I/O on a secondary thread whenever possible. 
> Every I/O you perform on the UI thread is an opportunity for hangs or 
> unresponsiveness. Grand Central Dispatch is your friend here.

Maybe better said in an "you should always perform IO in an async
fashion, aka never block user interaction with IO (or other
potentially long running tasks)". Various APIs provide async modes
without having to deal with threads however the task model of GCD and
the related high-level APIs that have been retooled to use it work
well for this.

-Shawn
___

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: Problem with MakeKeyandOrderFront

2010-10-05 Thread Amy Gibbs
I'll give that a go however it works fine in Xcode and by itself with a 
blank/new data file

Sent from my iPhone

On 5 Oct 2010, at 20:59, Ken Thomases  wrote:

> On Oct 5, 2010, at 1:55 PM, Amy Heavey wrote:
> 
>> Now when I click the button the focus goes from the main window but the 
>> second window doesn't appear. If I move the data file it works fine. Have I 
>> just overloaded it already? Even if all I do is open the app and go to the 
>> second tab and click the button, nothing?
> 
> Check the console log (either in Xcode's console window or the main console 
> log viewable with Console.app, depending on how you ran your app).  I bet 
> you're getting an exception, which is just prematurely terminating some 
> operation within your app.
> 
> If you're running in the debugger, enable breakpoints and "Stop on 
> Objective-C Exceptions" in Xcode's Run menu.
> 
> 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:
> http://lists.apple.com/mailman/options/cocoa-dev/home%40willowtreecrafts.co.uk
> 
> This email sent to h...@willowtreecrafts.co.uk
___

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


NSImage is Caching

2010-10-05 Thread Chris Tracewell
I have an NSImageView that accepts an image drop then sizes the image and ftp's 
it to a web server. The image view is bound to myObject.myImage property which 
set by a window controller calling its loadMyImage every time the window 
opens...


-(void)loadMyImage
{
NSImage *theImage = [[NSImage alloc] initWithContentsOfURL: theURL];
[self setMyImage: theImage];
}

The problem is that the image is being cached and I cannot figure out how. I 
can drop images galore and it ftp's them to their final destination --> which 
is where the image is loaded from. However, the image will stay the same even 
when I destroy myObject, create another one and it calls loadMyImage method 
again. Even between application restarts. 

This must be a setting in NSURL or NSURLConnection or NSURLCache, anyone have a 
clue as to where to start? FWIW - my web browser always shows the freshest 
image.

Thanks in advance.

-- chris

___

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: NSImage is Caching

2010-10-05 Thread Jonathon Kuo
You're missing a [theImage release] at the end of your method.

On Oct 5, 2010, at 2:46 PM, Chris Tracewell wrote:

> I have an NSImageView that accepts an image drop then sizes the image and 
> ftp's it to a web server. The image view is bound to myObject.myImage 
> property which set by a window controller calling its loadMyImage every time 
> the window opens...
> 
> 
> -(void)loadMyImage
>   {
>   NSImage *theImage = [[NSImage alloc] initWithContentsOfURL: theURL];
>   [self setMyImage: theImage];
>   }
> 
> The problem is that the image is being cached and I cannot figure out how. I 
> can drop images galore and it ftp's them to their final destination --> which 
> is where the image is loaded from. However, the image will stay the same even 
> when I destroy myObject, create another one and it calls loadMyImage method 
> again. Even between application restarts. 
> 
> This must be a setting in NSURL or NSURLConnection or NSURLCache, anyone have 
> a clue as to where to start? FWIW - my web browser always shows the freshest 
> image.
> 
> Thanks in advance.
> 
> -- chris
> 
> ___
> 
> 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/newslists%40autonomy.caltech.edu
> 
> This email sent to newsli...@autonomy.caltech.edu
> 

___

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: NSImage is Caching

2010-10-05 Thread Chris Tracewell
Shoulda said I'm using GC


On Oct 5, 2010, at 2:56 PM, Jonathon Kuo wrote:

> You're missing a [theImage release] at the end of your method.
> 
> On Oct 5, 2010, at 2:46 PM, Chris Tracewell wrote:
> 
>> I have an NSImageView that accepts an image drop then sizes the image and 
>> ftp's it to a web server. The image view is bound to myObject.myImage 
>> property which set by a window controller calling its loadMyImage every time 
>> the window opens...
>> 
>> 
>> -(void)loadMyImage
>>  {
>>  NSImage *theImage = [[NSImage alloc] initWithContentsOfURL: theURL];
>>  [self setMyImage: theImage];
>>  }
>> 
>> The problem is that the image is being cached and I cannot figure out how. I 
>> can drop images galore and it ftp's them to their final destination --> 
>> which is where the image is loaded from. However, the image will stay the 
>> same even when I destroy myObject, create another one and it calls 
>> loadMyImage method again. Even between application restarts. 
>> 
>> This must be a setting in NSURL or NSURLConnection or NSURLCache, anyone 
>> have a clue as to where to start? FWIW - my web browser always shows the 
>> freshest image.
>> 
>> Thanks in advance.
>> 
>> -- chris
>> 
>> ___
>> 
>> 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/newslists%40autonomy.caltech.edu
>> 
>> This email sent to newsli...@autonomy.caltech.edu
>> 
> 
> 

___

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: NSOutlineView multi cell type binding query

2010-10-05 Thread Quincey Morris
On Oct 5, 2010, at 03:53, jonat...@mugginsoft.com wrote:

> However it appears that the binding machinery causes the NSPopUpButtonCell 
> selection to be reset after the user has interacted with the control.
> 
> I therefore have to resync the NSPopUpButtonCell selection to the model in - 
> outlineView:willDisplayCell:forTableColumn:item:

If I understand you correctly, then it's not the binding machinery that 
"resets" anything.

Instead, it's understood (as part of NSTableView's API contract) that the cell 
in outlineView:willDisplayCell:forTableColumn:item: is re-configured every time 
it is used, since it's potentially re-used for multiple rows. It's not 
surprising that you would have to set up the selected item(s) every time.

Or did I misunderstand what you're asking?


___

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: NSOutlineView multi cell type binding query

2010-10-05 Thread jonat...@mugginsoft.com

On 5 Oct 2010, at 23:03, Quincey Morris wrote:

> On Oct 5, 2010, at 03:53, jonat...@mugginsoft.com wrote:
> 
>> However it appears that the binding machinery causes the NSPopUpButtonCell 
>> selection to be reset after the user has interacted with the control.
>> 
>> I therefore have to resync the NSPopUpButtonCell selection to the model in - 
>> outlineView:willDisplayCell:forTableColumn:item:
> 
> If I understand you correctly, then it's not the binding machinery that 
> "resets" anything.
> 
> Instead, it's understood (as part of NSTableView's API contract) that the 
> cell in outlineView:willDisplayCell:forTableColumn:item: is re-configured 
> every time it is used, since it's potentially re-used for multiple rows. It's 
> not surprising that you would have to set up the selected item(s) every time.
> 
> Or did I misunderstand what you're asking?
Quincey

I probably didn't clarify the issue enough, sorry.

I have a separate NSPopUpButtonCell that I recycle and configure as and when 
required.
The issue is that when the NSPopUpButtonCell is selected and the user selects 
an item from the popup NSMenu the user's selection is reset.
ie: say the user selects item 3, when the NSMenu is dismissed the 
NSPopupButtonCell is reset to display item 1.

In the action method the NSPopupButtonCell selected item is correct (item 3) 
and I update my model accordingly.
It is after this that the NSPopupButtonCell selection is reset.
I have to nudge it back to the required model state in - 
outlineView:willDisplayCell:forTableColumn:item:

I can only assume that the binding machinery that is servicing the 
NSValueBinding on the NSTextFieldCells is futzing with my NSPopupButtonCell.

Regards

Jonathan Mitchell

Developer
Mugginsoft LLP
http://www.mugginsoft.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: NSOutlineView multi cell type binding query

2010-10-05 Thread Quincey Morris
On Oct 5, 2010, at 15:36, jonat...@mugginsoft.com wrote:

> I have a separate NSPopUpButtonCell that I recycle and configure as and when 
> required.
> The issue is that when the NSPopUpButtonCell is selected and the user selects 
> an item from the popup NSMenu the user's selection is reset.
> ie: say the user selects item 3, when the NSMenu is dismissed the 
> NSPopupButtonCell is reset to display item 1.
> 
> In the action method the NSPopupButtonCell selected item is correct (item 3) 
> and I update my model accordingly.
> It is after this that the NSPopupButtonCell selection is reset.
> I have to nudge it back to the required model state in - 
> outlineView:willDisplayCell:forTableColumn:item:

What does "nudge" mean here? If you mean that 
outlineView:willDisplayCell:forTableColumn:item: is being called again, then, 
yes, you can't expect the cell to be configured as it was, even if you're 
reusing the same cell.

If you mean you're forcing a display update *in order to* get 
outlineView:willDisplayCell:forTableColumn:item: called again so that the view 
shows the correct setting, then I'd begin to suspect that your model property 
isn't properly KVO compliant.

Incidentally, are you binding the cell's selectedIndex (or whatever), or the 
table column's?


___

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


Problem connecting to Oracle with app run from XCode

2010-10-05 Thread Timothy Mowlem
Hello,

I am trying to get OCILib (http://orclib.sourceforge.net/), a free Oracle 
library, running on MacOSX. I have built the library from source and 
successfully run a test class via the terminal containing the example code in 
the OCILib documentation. As an experiment I have created a Cocoa app in XCode 
and dumped the code in the test class in the App delegate's 
applicationDidFinishLaunching method.

However when I run the app from within XCode I get the following error:

ORA-12170: TNS:Connect timeout occurred

Has anyone tried anything similar or seen a similar problem?

Oracle 10 XE running on a CentOS 5.5 VM in VMWare Fusion

I know the DB is up and running since I can connect to it using DBVisualizer 
and my command line tool runs fine.
I have tried turning off the firewall on both the MacOSX and CentOS but to no 
avail.
I have also tried su to the admin user and then running XCode from the terminal 
as root with sudo open 
Via printfs I know the initialize call is working.

Here is the code:

- (void) applicationDidFinishLaunching: (NSNotification *) aNotification
{
printf ("--> A\n");

OCI_Connection* cn;
OCI_Statement* st;
OCI_Resultset* rs;

if (!OCI_Initialize (NULL, NULL, OCI_ENV_CONTEXT))
{
OCI_Error *error = OCI_GetLastError();
printf ("--> Initialize failed: code = %d, msg = %s\n", 
OCI_ErrorGetOCICode (error), OCI_ErrorGetString (error));
OCI_Cleanup();
return;
}

printf ("--> B\n");

cn = OCI_ConnectionCreate ("xe", "ddi", "kitty", OCI_SESSION_DEFAULT);
if (cn == NULL)
{
OCI_Error *error = OCI_GetLastError();
printf ("--> Create connection failed: code = %d, msg = %s\n", 
OCI_ErrorGetOCICode (error), OCI_ErrorGetString (error));
OCI_Cleanup();
return; 
}

printf (OCI_GetVersionServer(cn));

st = OCI_StatementCreate (cn);
if (st == NULL)
{
OCI_Error *error = OCI_GetLastError();
printf ("--> Create statement failed: code = %d, msg = %s\n", 
OCI_ErrorGetOCICode (error), OCI_ErrorGetString (error));
OCI_Cleanup();
return; 
}

OCI_ExecuteStmt (st, "select count(*) from location");
rs = OCI_GetResultset (st);
while (OCI_FetchNext (rs))
{
printf ("Locations = %d\n", OCI_GetInt (rs, 1));
}

OCI_Cleanup();
}

So the create connection step is failing. I can see the main thread waiting for 
the connection as I get the spinning color wheel cursor. It times out after 
about 30-45 seconds. Running the same code in a simple .c file runs instantly.

Any help appreciated.


Thanks.

Tim Mowlem___

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: NSOutlineView multi cell type binding query

2010-10-05 Thread Corbin Dunn

On Oct 5, 2010, at 3:36 PM, jonat...@mugginsoft.com wrote:

> 
> On 5 Oct 2010, at 23:03, Quincey Morris wrote:
> 
>> On Oct 5, 2010, at 03:53, jonat...@mugginsoft.com wrote:
>> 
>>> However it appears that the binding machinery causes the NSPopUpButtonCell 
>>> selection to be reset after the user has interacted with the control.
>>> 
>>> I therefore have to resync the NSPopUpButtonCell selection to the model in 
>>> - outlineView:willDisplayCell:forTableColumn:item:
>> 
>> If I understand you correctly, then it's not the binding machinery that 
>> "resets" anything.
>> 
>> Instead, it's understood (as part of NSTableView's API contract) that the 
>> cell in outlineView:willDisplayCell:forTableColumn:item: is re-configured 
>> every time it is used, since it's potentially re-used for multiple rows. 
>> It's not surprising that you would have to set up the selected item(s) every 
>> time.
>> 
>> Or did I misunderstand what you're asking?
> Quincey
> 
> I probably didn't clarify the issue enough, sorry.
> 
> I have a separate NSPopUpButtonCell that I recycle and configure as and when 
> required.
> The issue is that when the NSPopUpButtonCell is selected and the user selects 
> an item from the popup NSMenu the user's selection is reset.
> ie: say the user selects item 3, when the NSMenu is dismissed the 
> NSPopupButtonCell is reset to display item 1.
> 
> In the action method the NSPopupButtonCell selected item is correct (item 3) 
> and I update my model accordingly.
> It is after this that the NSPopupButtonCell selection is reset.
> I have to nudge it back to the required model state in - 
> outlineView:willDisplayCell:forTableColumn:item:
> 
> I can only assume that the binding machinery that is servicing the 
> NSValueBinding on the NSTextFieldCells is futzing with my NSPopupButtonCell.

I think it is your misunderstanding of what is going on. 

When the user interacts with a cell (editing, or tracking - in this case, 
tracking is happening), the cell is copied. This is required, if you think 
about it, since you don't want to have any other cells in the table be redrawn 
with that cell that is in the middle of being edited/tracked. After editing, 
the regular cell is used again to do drawing for that row/column. The edited 
cell needs to be redrawn; you can use - 
(void)reloadDataForRowIndexes:(NSIndexSet *)rowIndexes 
columnIndexes:(NSIndexSet *)columnIndexes, which in 10.6 basically just does a 
setNeedsDisplayInRect:.

corbin

___

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: Problem with MakeKeyandOrderFront

2010-10-05 Thread Amy Heavey

nothing in the main console app.

I only have this problem using the large data file I've created. I've  
been adding data to the app and now this just won't work. If I move  
the xml file or the app it's fine. It's fine running in xcode too.


I think I'll have to move to an sqllite store and start all over again,

Amy

On 5 Oct 2010, at 20:59, Ken Thomases wrote:


On Oct 5, 2010, at 1:55 PM, Amy Heavey wrote:

Now when I click the button the focus goes from the main window but  
the second window doesn't appear. If I move the data file it works  
fine. Have I just overloaded it already? Even if all I do is open  
the app and go to the second tab and click the button, nothing?


Check the console log (either in Xcode's console window or the main  
console log viewable with Console.app, depending on how you ran your  
app).  I bet you're getting an exception, which is just prematurely  
terminating some operation within your app.


If you're running in the debugger, enable breakpoints and "Stop on  
Objective-C Exceptions" in Xcode's Run menu.


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

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