How to retrieve a vCard during an ISyncSession?

2010-06-30 Thread unixo
Hi,

I'm writing a sync client which pulls Contacts entity from sync server; an 
unique identifier is associated with each record: given an ID, is there a way 
to load the corresponding vCard from address book?

Even if data are similar (except for suffix :ABPerson), I can't find a record 
using recordsMatchingSearchElement: method.
ISyncChange UID: 04854671-4DD3-41C8-9601-3AE65C1AAEA1
AddressBook UID: C8CD9946-D629-4CD1-90A4-F270190AC4A0:ABPerson

Any ideas?

Thanks in advance!___

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 retrieve a vCard during an ISyncSession?

2010-06-30 Thread Laurent Cerveau
Why would you want to retrieve the vCard? The sync engine can give you all 
attributes for a record. Or maybe AddressBook framework is more suited to your 
needs

laurent 

Sent from my road phone


On Jun 30, 2010, at 7:59 AM, unixo un...@devzero.it wrote:

 Hi,
 
 I'm writing a sync client which pulls Contacts entity from sync server; an 
 unique identifier is associated with each record: given an ID, is there a way 
 to load the corresponding vCard from address book?
 
 Even if data are similar (except for suffix :ABPerson), I can't find a 
 record using recordsMatchingSearchElement: method.
 ISyncChange UID: 04854671-4DD3-41C8-9601-3AE65C1AAEA1
 AddressBook UID: C8CD9946-D629-4CD1-90A4-F270190AC4A0:ABPerson
 
 Any ideas?
 
 Thanks in advance!___
 
 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/lcerveau%40me.com
 
 This email sent to lcerv...@me.com
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: OpenAL and OGG

2010-06-30 Thread Eric Wing
On 6/29/10, Development developm...@fornextsoft.com wrote:
 Can open al not read ogg files? I'm attempting to load a short ogg clip and
 I keep getting random errors.

 getOpenALAudioData: ExtAudioFileOpenURL FAILED, Error = 1954115647
 2010-06-29 15:13:53.965 MixPad[12402:207] error attaching audio to buffer:
 a003



 this is the file loading code, it is directly from an apple example

   ALenum  error = AL_NO_ERROR;
   ALenum  format;
   ALsizei size;
   ALsizei freq;
   
   //NSBundle* bundle = [NSBundle mainBundle];
   
   // get some audio data from a wave file
   CFURLRef fileURL = (CFURLRef)[[NSURL fileURLWithPath:self.path] retain];
   
   if (fileURL)
   {   
   data = getOpenALAudioData(fileURL, size, format, freq);
   CFRelease(fileURL);
   
   if((error = alGetError()) != AL_NO_ERROR) {
   NSLog(@error loading sound: %x\n, error);
   exit(1);
   }
   
   // use the static buffer data API
   alBufferDataStaticProc(self.alBufferID, format, data, size, 
 freq);
   
   NSLog(@Format %i,format);
   NSLog(@Data %i,sizeof(data));
   
   if((error = alGetError()) != AL_NO_ERROR) {
   NSLog(@error attaching audio to buffer: %x\n, error);
   }   
   }
   else
   NSLog(@Could not find
 file!\n);___


OpenAL is format agnostic. It doesn't know anything about file types.
It only accepts bytes of linear PCM.

Apple / Core Audio don't natively support Ogg.

Generally, if you want to use Ogg, you have to compile in the Ogg
Vorbis libraries from Xiph and use their APIs. ov_read() would be good
place to start looking.

-Eric
http://playcontrol.net/iphonegamebook
___

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


Best way to compare CGFloats

2010-06-30 Thread Rimas M.
Hello,

I am stuck with floats (doubles, to be precise) comparison.
In part of my app, I am dealing with NSPoint components (x, y)
comparison. On 32bit architecture NSPoint components are floats, and
direct comparison ( float1 == float2 ) works fine. But on 64bit, they
are doubles and '==' does not work due to precision.

Lets take an example: C and D are NSPoints. Lets say C is
(1.000444089209850063, whatever) and D is
(1.00, whatever).
If my code is: if (C.x == D.x) thenDoSomething; , then thenDoSomething
is not called. Of course.

But on my needs, float is more than enough for precision.

So question is, what is the most efficient (performance side) and
simplest (coding side) way to compare those bastards?

At the moment I am thinking about:

a) BOOL _floatsOrDoublesAreEqual = ( (float)C.x == (float)D.x);

b) BOOL _floatsOrDoublesAreEqual = ( fabs(C.x - D.x) = _epsilon ); ,
where _epsilon is something like 0.0001.

Regards,

Rimas M.
___

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 drawing on 10.5 issue

2010-06-30 Thread Ken Ferry
On Mon, Jun 28, 2010 at 8:24 PM, Graham Cox graham@bigpond.com wrote:

 I have an NSImage which I generate by specifically creating a NSPDFImageRep
 and adding that to an empty image. Later this same image rep is used to
 write the image as a PDF file to disk.

 An interface displays these images, either loaded from disk or made on the
 fly as above. The image's native size is quite small and they are often
 scaled up when drawn, but since they're PDFs that should work OK.

 On 10.6, these render really nicely and I always get crisp drawing. On 10.5
 however, they render quite fuzzily, which I'd prefer they didn't.

 Obviously the problem is the bitmap caching that NSImage does, and which
 must have changed for PDF images in 10.6. I set the caching of the image to
 NSImageCacheBySize, which gives me a useful drawing speed-up compared with
 NSImageCacheNever, but the cached bitmaps are fuzzy on 10.5, presumably
 because they're being scaled up and the bitmaps cached the original size,
 not the drawn size. Is there anything I can do about this?

 I set the context's image interpolation quality to high when these are
 drawn.


Hi Graham,

I'm a lot more familiar with the post-10.6 code than the 10.5 and before
code, but I think you probably need to either turn off the cache or
essentially manage your own cache by replacing the image when the scaling
changes.

Given that this problem is fixed in newer OSes, I would be tempted to just
turn off the cache in 10.5.

-Ken
Cocoa Frameworks



 --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/kenferry%40gmail.com

 This email sent to kenfe...@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/archive%40mail-archive.com

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


Re: Best way to compare CGFloats

2010-06-30 Thread Roland King
I usually use fabs() and compare to some small number for things like this, it 
explicitly says what your tolerance for 'same' is and if your points are going 
through a series of calculations, it's easy to get them to differ in the lower 
order bits however you cast them. 


On 30-Jun-2010, at 4:35 PM, Rimas M. wrote:

 Hello,
 
 I am stuck with floats (doubles, to be precise) comparison.
 In part of my app, I am dealing with NSPoint components (x, y)
 comparison. On 32bit architecture NSPoint components are floats, and
 direct comparison ( float1 == float2 ) works fine. But on 64bit, they
 are doubles and '==' does not work due to precision.
 
 Lets take an example: C and D are NSPoints. Lets say C is
 (1.000444089209850063, whatever) and D is
 (1.00, whatever).
 If my code is: if (C.x == D.x) thenDoSomething; , then thenDoSomething
 is not called. Of course.
 
 But on my needs, float is more than enough for precision.
 
 So question is, what is the most efficient (performance side) and
 simplest (coding side) way to compare those bastards?
 
 At the moment I am thinking about:
 
 a) BOOL _floatsOrDoublesAreEqual = ( (float)C.x == (float)D.x);
 
 b) BOOL _floatsOrDoublesAreEqual = ( fabs(C.x - D.x) = _epsilon ); ,
 where _epsilon is something like 0.0001.
 
 Regards,
 
 Rimas M.
 ___
 
 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/rols%40rols.org
 
 This email sent to r...@rols.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: Best way to compare CGFloats

2010-06-30 Thread Jean-Daniel Dupas

Le 30 juin 2010 à 10:35, Rimas M. a écrit :

 Hello,
 
 I am stuck with floats (doubles, to be precise) comparison.
 In part of my app, I am dealing with NSPoint components (x, y)
 comparison. On 32bit architecture NSPoint components are floats, and
 direct comparison ( float1 == float2 ) works fine. But on 64bit, they
 are doubles and '==' does not work due to precision.
 
 Lets take an example: C and D are NSPoints. Lets say C is
 (1.000444089209850063, whatever) and D is
 (1.00, whatever).
 If my code is: if (C.x == D.x) thenDoSomething; , then thenDoSomething
 is not called. Of course.
 
 But on my needs, float is more than enough for precision.
 
 So question is, what is the most efficient (performance side) and
 simplest (coding side) way to compare those bastards?
 
 At the moment I am thinking about:
 
 a) BOOL _floatsOrDoublesAreEqual = ( (float)C.x == (float)D.x);
 
 b) BOOL _floatsOrDoublesAreEqual = ( fabs(C.x - D.x) = _epsilon ); ,
 where _epsilon is something like 0.0001.
 

You should not rely on the fact that it works with float. Comparing floating 
point value is never safe.

So, as the solution a does not solve the problem (you cannot safely compare 
floating point value), I would choose the b.


-- Jean-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: Best way to compare CGFloats

2010-06-30 Thread Alastair Houghton
On 30 Jun 2010, at 09:35, Rimas M. wrote:

 So question is, what is the most efficient (performance side) and
 simplest (coding side) way to compare those bastards?
 
 At the moment I am thinking about:
 
 a) BOOL _floatsOrDoublesAreEqual = ( (float)C.x == (float)D.x);
 
 b) BOOL _floatsOrDoublesAreEqual = ( fabs(C.x - D.x) = _epsilon ); ,
 where _epsilon is something like 0.0001.

fabs is the right way to do this in most cases, *but* with co-ordinate values 
it may be that you are actually more interested in the distance of one point 
from the other---i.e. you might in fact be interested in

  CGFloat dx = C.x - D.x, dy = C.y - D.y;
  BOOL pointsAreEqual = (dx * dx + dy * dy)  epsilonSquared;

It rather depends on what you want, and that's going to differ from one 
application to another.

Kind regards,

Alastair.

--
http://alastairs-place.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


CALayer-hosting view and child NSView's

2010-06-30 Thread Oleg Krupnov
Hi,

I'd like to create a custom view based on Core Animation, namely, a
layer-hosting view. In other words, I'd like to directly manipulate
layers in my code rather than using children NSView's.

The custom view is like a matrix consisting of cells. Each cell is
represented with a separate CALayer.

However, certain cells should contain standard buttons like if they
were child views of those cell layers. In other words, when I move
the cell layer, the button needs to move synchronously; when I hide
the cell layer, the button needs to hide as well.

I would like to use the standard NSButton control, to avoid
reinventing the wheel.

But if I just place the button as a first-level child view of the
custom view, it will not be associated with its parent cell layer. I
also cannot access and manipulate NSButton's root layer to add it as a
sublayer to the cell layer, AFAIK.

So what is the best way around?


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/archive%40mail-archive.com

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


Re: Best way to compare CGFloats

2010-06-30 Thread Rimas M.
Thanks everyone for answers. Now situation is more clear.

On Wed, Jun 30, 2010 at 12:14 PM, Alastair Houghton
alast...@alastairs-place.net wrote:

 fabs is the right way to do this in most cases, *but* with co-ordinate values 
 it may be that you are actually more interested in the distance of one point 
 from the other---i.e. you might in fact be interested in

  CGFloat dx = C.x - D.x, dy = C.y - D.y;
  BOOL pointsAreEqual = (dx * dx + dy * dy)  epsilonSquared;

 It rather depends on what you want, and that's going to differ from one 
 application to another.

In my case I am interested in x's and y's comparison. Not points as
themselves. But your suggestion gave me another question, which I have
never thought about before - how NSEqualPoints, ...Rects etc works? I
guess they *must* be safe to use, because NSPoint, NSRect etc relies
on floats/doubles. Or they uses the same '==' and are TRUE only if
points/rects are *really* equal?

Best Regards,

Rimas M.
___

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: Best way to compare CGFloats

2010-06-30 Thread Alastair Houghton
On 30 Jun 2010, at 10:46, Rimas M. wrote:

 In my case I am interested in x's and y's comparison. Not points as
 themselves. But your suggestion gave me another question, which I have
 never thought about before - how NSEqualPoints, ...Rects etc works? I
 guess they *must* be safe to use, because NSPoint, NSRect etc relies
 on floats/doubles. Or they uses the same '==' and are TRUE only if
 points/rects are *really* equal?

I think they test for exact equality.  Whether that's documented or not I'm
not certain, but disassembling those functions appears to support that
conclusion.

Kind regards,

Alastair.

--
http://alastairs-place.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: NSImage drawing on 10.5 issue

2010-06-30 Thread Graham Cox

On 30/06/2010, at 6:36 PM, Ken Ferry wrote:

 On Mon, Jun 28, 2010 at 8:24 PM, Graham Cox graham@bigpond.com wrote:
 I have an NSImage which I generate by specifically creating a NSPDFImageRep 
 and adding that to an empty image. Later this same image rep is used to write 
 the image as a PDF file to disk.
 
 An interface displays these images, either loaded from disk or made on the 
 fly as above. The image's native size is quite small and they are often 
 scaled up when drawn, but since they're PDFs that should work OK.
 
 On 10.6, these render really nicely and I always get crisp drawing. On 10.5 
 however, they render quite fuzzily, which I'd prefer they didn't.
 
 Obviously the problem is the bitmap caching that NSImage does, and which must 
 have changed for PDF images in 10.6. I set the caching of the image to 
 NSImageCacheBySize, which gives me a useful drawing speed-up compared with 
 NSImageCacheNever, but the cached bitmaps are fuzzy on 10.5, presumably 
 because they're being scaled up and the bitmaps cached the original size, not 
 the drawn size. Is there anything I can do about this?
 
 I set the context's image interpolation quality to high when these are drawn.
 
 Hi Graham,
 
 I'm a lot more familiar with the post-10.6 code than the 10.5 and before 
 code, but I think you probably need to either turn off the cache or 
 essentially manage your own cache by replacing the image when the scaling 
 changes.  
 
 Given that this problem is fixed in newer OSes, I would be tempted to just 
 turn off the cache in 10.5.


Hi Ken, thanks for the suggestion.

I've tried that, but the results are strange - I'm not sure I really understand 
what's going on.

When I render these icons, I do so in a custom cell which can either operate 
using NSImageScaleProportionallyDown, or NSImageScaleProportionallyUpOrDown. 
The user is able to switch between these to show icons either at actual size 
(or smaller), or scaled up to fill the cell.

Whichever one is displayed first, it seems to fix the resolution of the icon 
at that size forever after, even though caching is supposedly off and the cache 
has been cleared (-recache). So it's still caching the PDF to a bitmap it 
seems, at least on 10.5 (As I said on 10.6 I have none of these issues).

Do I need to manipulate the cache setting for the PDF image rep itself? I 
thought that whatever you set NSImage to do applied to all its reps, no? The 
docs say that NSPDFImageRep sets NSImageCacheAlways by default, so does passing 
'never' to its containing image actually change this?

The cell drawing code is clean, as far as I can see (does nothing but draw the 
image, it doesn't change the image's state in any way), and loading the icon is 
little more than doing [NSImage imageWithContentsOfFile:] followed by setting 
the cache to NSImageCacheNever and calling -recache.

Mystified..

--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: NSImage drawing on 10.5 issue

2010-06-30 Thread Graham Cox

On 30/06/2010, at 10:22 PM, Graham Cox wrote:

 Do I need to manipulate the cache setting for the PDF image rep itself?


The answer must be 'no', since there's no API to do so...

--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: NSImage drawing on 10.5 issue [SOLVED]

2010-06-30 Thread Graham Cox

On 30/06/2010, at 10:22 PM, Graham Cox wrote:

 Given that this problem is fixed in newer OSes, I would be tempted to just 
 turn off the cache in 10.5.
 
 
 Hi Ken, thanks for the suggestion.
 
 I've tried that, but the results are strange - I'm not sure I really 
 understand what's going on.


OK, I found the answer (turn off caching, as you suggested ;) The problem was 
the branch that was supposed to do this on 10.5 wasn't being taken due to a 
faulty test for the appkit version. Fixed that and now all is well (with 
slightly slower drawing, but I can live with it).

thanks again,

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: Best way to compare CGFloats

2010-06-30 Thread Rimas M.
On Wed, Jun 30, 2010 at 1:06 PM, Alastair Houghton
alast...@alastairs-place.net wrote:
 I think they test for exact equality.  Whether that's documented or not I'm
 not certain, but disassembling those functions appears to support that
 conclusion.

I see. Hope that will not cause any unexpected problems. For now I am
going to use:

#define cDefaultFloatComparisonEpsilon  0.0001
#define cEqualFloats(f1, f2, epsilon)   ( fabs( (f1) - (f2) )  epsilon )
#define cNotEqualFloats(f1, f2, epsilon)( !cEqualFloats(f1, f2, 
epsilon) )

Thank you for your help.

Regards,

Rimas M.
___

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: Best way to compare CGFloats (Rick B.)

2010-06-30 Thread Frederick Bartram

I am stuck with floats (doubles, to be precise) comparison.


Machine 'real-numbers' such as floats and doubles should be thought of  
as intervals or neighborhoods near the mathematical number. Tests for  
'equality' of machine reals should never use machine equality '=='  
operators. 'Equality' of two machine reals , in this case, means that  
the two numbers are separated by a distance less than some small  
number, such as '(fabs(a-b)  epsilon)'. Exactly what the value of  
epsilon should be gets a little tricky.


Hope that I am not being too pedantic but imo you should never test  
for 'equality' ('==') when using machine real data types.


Rick B.
*-
* Stop spam before it gets to your mailbox! Support blocklists.
* I use http://www.spamcop.net/.
* my PGP key id: 0x63fa758 keyserver: http://keyserver1.pgp.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: Best way to compare CGFloats (Rick B.)

2010-06-30 Thread Alastair Houghton
On 30 Jun 2010, at 15:56, Frederick Bartram wrote:

 Hope that I am not being too pedantic but imo you should never test for 
 'equality' ('==') when using machine real data types.

Sometimes you really do want binary equivalence, and in that case == may be the 
right thing to use.  Normally, though, you're quite right, you need to be 
careful with floating point comparisons (not just equality tests, actually; 
sometimes for greater-than or less-than comparisons you might want two floats 
to be un-ordered if they're close in value).

I thought it'd be useful to link to the excellent What Every Computer 
Scientist Should Know About Floating-Point Arithmetic, since that's usually 
the best thing to give to people who are worrying about this kind of thing:

http://dlc.sun.com/pdf/800-7895/800-7895.pdf
http://docs.sun.com/source/806-3568/ncg_goldberg.html

Anyone who hasn't read it should.

Kind regards,

Alastair.

-- 
http://alastairs-place.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: Best way to compare CGFloats (Rick B.)

2010-06-30 Thread Michael Ash
On Wed, Jun 30, 2010 at 11:11 AM, Alastair Houghton
alast...@alastairs-place.net wrote:
 On 30 Jun 2010, at 15:56, Frederick Bartram wrote:

 Hope that I am not being too pedantic but imo you should never test for 
 'equality' ('==') when using machine real data types.

 Sometimes you really do want binary equivalence, and in that case == may be 
 the right thing to use.

While we're being pedantic, note that == is not always the same as
binary equivalence. For example, 0.0 == -0.0, and x != x when x =
NAN.

Using == can make sense when you know that your values are exact
integers, which is not an uncommon scenario, but neither is it the
usual one.

Mike
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Calling javascript from Cocoa 'facelessly'

2010-06-30 Thread Geoffrey Holden
My company has a webpage (internal, sadly, so I can't let you have a link to 
look at) which is entirely driven by Javascript, and which requires 
authentication to access (the authentication too is driven by Javascript, 
rather than by the more normal https sign in methods).

The website is a) ugly as hell, b) not very flexible and c) won't format 
correctly on the screen of an iPhone.  The first issue is aesthetic, the second 
is a serious issue and the third could well be a problem in the future.

The obvious answer would be 'change the site', but that isn't very practical 
sadly - political issue, don'tchaknow!  I'm working hard to increase uptake of 
Apple equipment at work, and if I can encapsulate the website as a friendly app 
on the Mac that could be a major driver.  This is just a project that I'm 
kicking around out of hours for the love of it and in the hope that Macs might 
end up being a preferred solution!

Initially, I just want to produce a proof of concept which runs at the command 
line (the connection will be implemented as a faceless plug in) and I don't 
want a webview in the UI.  So, that said, I cobbled together the following test:

//for header
IBOutlet WebView * webView;
NSDictionary* pluginPrefs;


//for body
NSString* preferencesFile = [NSHomeDirectory() 
stringByAppendingPathComponent:@/Desktop/Prefs.plist];

pluginPrefs = [[NSDictionary alloc] initWithContentsOfFile:preferencesFile];


WebFrame *mainFrame = [webView mainFrame];
NSURL *url = [NSURL URLWithString:[pluginPrefs objectForKey:@ServerURL]];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[mainFrame loadRequest:request];
  
id win = [webView windowScriptObject];

NSArray *args = [NSArray arrayWithObjects:
 @signIn,
 [pluginPrefs objectForKey:@Username],
 [pluginPrefs objectForKey:@Password],
 nil];


//login (in theory!)
NSLog(@Parameters: %@, %@,[pluginPrefs 
objectForKey:@Username],[pluginPrefs objectForKey:@Password]);
id result = [win callWebScriptMethod:@muc.userAuth withArguments:args];
if(![result isMemberOfClass:[WebUndefined class]]) 
NSLog(@%@, result);
else
NSLog(@Unable to initialize connection);

The code builds correctly, and runs - but, just for starters, the result seems 
to be wrong (it should return 'Unable to initialize connection' as far as I can 
tell), because it always returns the same result whether I have a 'valid' 
javascript function or not.  Of course, once (if!) I get it to connect 
correctly, I then need to solve the problem of capturing the stream of messages 
that will be received in not-quite-real-time. I'll cross that bridge when I 
come to it.

The muc.userAuth function can be found in and external .js file, referenced in 
the page html with the following tag:
script type=text/javascript src=../js/ejc.js?ver=2.0.1.1/script

I realize that this is a hell of a big query, and I'm not entirely sure that 
I've given enough information for anyone to help answer it.  At the very least, 
I guess I'm hoping for a reference to some really solid documentation on how to 
do what I'm trying to do - the documentation on ADC seems to be a little light 
in this area.

Thanks, and regards,

Geoff___

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: Tracking multiple NSURLConnections

2010-06-30 Thread aglee

(Coming late to this thread...)

I recently used both approaches.  Subclassing NSURLConnection worked nicely and 
was quick to code when I had just one kind of delegate behavior.  When I had to 
add other kinds of delegate behavior I switched to the 
multiple-delegate-classes approach and used plain NSURLConnection.

My classes are lightweight wrappers that hide the NSURLConnection machinery and 
define their own delegates (this is the weak pointer Dave described).  My 
classes' delegates are notified when either (1) the connection fails, (2) the 
connection finishes getting the data and the data is invalid, or (3) the 
connection finishes getting the data and the data is okay.

This was my first time using NSURLConnection, so I'm glad each of the two 
approaches I used makes sense to at least one other person. :)

--Andy


On 29 Jun, 2010,at 03:31 PM, Stevo Brock st...@monkey-tools.com wrote:

You could also subclass NSURLConnection and add any additional data to your 
subclass that you can easily access in the callbacks.

On Jun 29, 2010, at 12:11 PM, Dave DeLong wrote:


If you're spawning dozens of connections, you may want to consider giving each 
one a separate delegate object and encapsulating that connection's specific 
logic in that delegate. The url connection delegate might then have a weak 
pointer back to the original controller to notify when the connection is 
finished, at which point the controller could extract any data it needs from 
the connection delegate.

Dave

On Jun 29, 2010, at 1:08 PM, lorenzo7...@gmail.com wrote:


Now, a devil's advocate question:
If I have lots of connections, say two dozen, or say I'm spawning connections 
continuously, would this be the most efficient way of doing this? I'd likely 
store them in an NSArray and iterate/compare until I find the right one. There 
could be lots of comparisons.

___

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/stevo%40monkey-tools.com

This email sent to st...@monkey-tools.com


-Stevo



___

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/aglee%40maccom

This email sent to ag...@mac.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: Calling javascript from Cocoa 'facelessly'

2010-06-30 Thread Michael Ash
On Wed, Jun 30, 2010 at 1:01 PM, Geoffrey Holden
45rpmli...@googlemail.com wrote:
 I realize that this is a hell of a big query, and I'm not entirely sure that 
 I've given enough information for anyone to help answer it.  At the very 
 least, I guess I'm hoping for a reference to some really solid documentation 
 on how to do what I'm trying to do - the documentation on ADC seems to be a 
 little light in this area.

From the code you've posted, I suspect the problem is that the page
hasn't actually loaded by the time you try to run your JS code.
WebView generally works asynchronously. Something like [mainFrame
loadRequest:request] will return quickly and the WebView will not
actually load things until the runloop runs, and then you'll get
notified later on when it's done loading.

What you'll want to do is call loadRequest:, then run the NSRunLoop on
the main thread until your load delegate is told that the page is done
loading. Then you should be able to do your JS stuff.

Note that it is possible, and not all that hard, to run an NSRunLoop
in a faceless program, it just requires a bit more manual intervention
than in a GUI app where it's all set up for you.

If you're already doing that and your code was just abbreviated, well,
ignore the above

Mike
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: NSOpenPanel won't allow selecting aliases

2010-06-30 Thread Sean McBride
On Tue, 29 Jun 2010 20:34:11 -0700, Seth Willits said:

Yes. I didn't quite realize that's what was happening. Hmm. So now I
have to figure out how allow aliases through in my delegate method.
Since they don't just pop up as folders, I have to find something that
identifies them as aliases to folders...

The NDAlias code should be helpful to you:
http://github.com/nathanday/ndalias

--

Sean McBride, B. Eng s...@rogue-research.com
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada


___

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: Best way to compare CGFloats (Rick B.)

2010-06-30 Thread Alastair Houghton
On 30 Jun 2010, at 17:37, Michael Ash wrote:

 While we're being pedantic, note that == is not always the same as
 binary equivalence. For example, 0.0 == -0.0, and x != x when x =
 NAN.

That's a good point.  I spoke inaccurately.

 Using == can make sense when you know that your values are exact
 integers, which is not an uncommon scenario, but neither is it the
 usual one.

It may also make sense sometimes with floating point values.  An example might 
be where you have an object that you're using as the key for an NSDictionary; 
in that case, your -isEqual: method may well want to do a proper equality test.

These are, however, special situations.

Kind regards,

Alastair.

--
http://alastairs-place.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


class_respondsToSelector() in runtime.h?

2010-06-30 Thread Laurent Daudelin
I need to check for backward compatibility whether a given class object 
responds to a selector. I found the function 'class_respondsToSelector()' which 
the doc says is defined in 'runtime.h'. However, I can't find that header 
anywhere.

Does anybody know where that header might be? No, it's not in /usr/include...

-Laurent.
-- 
Laurent Daudelin
AIM/iChat/Skype:LaurentDaudelin 
http://www.nemesys-soft.com/
Logiciels Nemesys Software  
laur...@nemesys-soft.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: class_respondsToSelector() in runtime.h?

2010-06-30 Thread Dave DeLong
#import objc/runtime.h

Dave

Sent from my iPhone

On Jun 30, 2010, at 1:43 PM, Laurent Daudelin laur...@nemesys-soft.com wrote:

 I need to check for backward compatibility whether a given class object 
 responds to a selector. I found the function 'class_respondsToSelector()' 
 which the doc says is defined in 'runtime.h'. However, I can't find that 
 header anywhere.
 
 Does anybody know where that header might be? No, it's not in /usr/include...
 
 -Laurent
___

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: class_respondsToSelector() in runtime.h?

2010-06-30 Thread Greg Parker
On Jun 30, 2010, at 12:43 PM, Laurent Daudelin wrote:
 I need to check for backward compatibility whether a given class object 
 responds to a selector. I found the function 'class_respondsToSelector()' 
 which the doc says is defined in 'runtime.h'. 

Is there some reason you can't call -respondsToSelector: on the class object? 


-- 
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: class_respondsToSelector() in runtime.h?

2010-06-30 Thread Laurent Daudelin
On Jun 30, 2010, at 16:55, Greg Parker wrote:

 On Jun 30, 2010, at 12:43 PM, Laurent Daudelin wrote:
 I need to check for backward compatibility whether a given class object 
 responds to a selector. I found the function 'class_respondsToSelector()' 
 which the doc says is defined in 'runtime.h'. 
 
 Is there some reason you can't call -respondsToSelector: on the class object? 
 

Well, isn't -respondsToSelector: an instance method?

-Laurent.
-- 
Laurent Daudelin
AIM/iChat/Skype:LaurentDaudelin 
http://www.nemesys-soft.com/
Logiciels Nemesys Software  
laur...@nemesys-soft.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: class_respondsToSelector() in runtime.h?

2010-06-30 Thread Kyle Sluder
On Jun 30, 2010, at 2:35 PM, Laurent Daudelin laur...@nemesys-soft.com wrote:

 On Jun 30, 2010, at 16:55, Greg Parker wrote:
 
 
 Is there some reason you can't call -respondsToSelector: on the class 
 object? 
 
 
 Well, isn't -respondsToSelector: an instance method?

Remember that NSObject is a root class.

--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: class_respondsToSelector() in runtime.h?

2010-06-30 Thread Laurent Daudelin
On Jun 30, 2010, at 17:41, Kyle Sluder wrote:

 On Jun 30, 2010, at 2:35 PM, Laurent Daudelin laur...@nemesys-soft.com 
 wrote:
 
 On Jun 30, 2010, at 16:55, Greg Parker wrote:
 
 
 Is there some reason you can't call -respondsToSelector: on the class 
 object? 
 
 
 Well, isn't -respondsToSelector: an instance method?
 
 Remember that NSObject is a root class.
 

Yes, I know that, but can you send an instance method to a class object?

-Laurent.
-- 
Laurent Daudelin
AIM/iChat/Skype:LaurentDaudelin 
http://www.nemesys-soft.com/
Logiciels Nemesys Software  
laur...@nemesys-soft.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: class_respondsToSelector() in runtime.h?

2010-06-30 Thread Dave Carrigan

On Jun 30, 2010, at 2:35 PM, Laurent Daudelin wrote:

 Well, isn't -respondsToSelector: an instance method?


if ([[Someclass class] respondsToSelector:@selector(classSelector)]) {
// yup
}

-- 
Dave Carrigan
d...@rudedog.org
Seattle, WA, USA

___

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: class_respondsToSelector() in runtime.h?

2010-06-30 Thread Greg Parker
On Jun 30, 2010, at 2:42 PM, Laurent Daudelin wrote:
 Yes, I know that, but can you send an instance method to a class object?

Yes, you can. Every class object is itself an instance of NSObject. Therefore, 
every class object also responds to all of NSObject's instance methods. 

http://sealiesoftware.com/blog/archive/2009/04/14/objc_explain_Classes_and_metaclasses.html

(Pedantically, every class object is itself an instance of its root class. But 
to a close approximation that root class is always NSObject.)


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


NSString ambiguities

2010-06-30 Thread Ariel Feinerman
Hi,

If we read whole file as a NSString, will be any conversions between \r\n,
\r, \n? Then if not, will be -componentsSeparatedByCharactersInSet:
[NSCharacterSet newlineCharacterSet] create empty strings in Win \r\n case?
So what is the best: [NSCharacterSet newlineCharacterSet] or [NSCharacterSet
characterSetWithCharactersInString: @\n] or simply
-componentsSeparatedByString: @\n?

code:

NSString *string = [[NSString alloc] initWithContentsOfFile: name encoding:
NSUTF8StringEncoding error: NULL];
NSArray *array = [string componentsSeparatedByCharactersInSet:
[NSCharacterSet newlineCharacterSet]];

[string release];
string = nil;

NSMutableString *outString = [NSString new];

for (string in array) {
 if (![string isEqualToString: @]) {
 // ...
 [outString appendFormat: @%...@\n, string];
 }
}

[outString writeToFile: outName atomically: NO encoding:
NSUTF8StringEncoding error: NULL];

-- 
best regards
Ariel
___

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: class_respondsToSelector() in runtime.h?

2010-06-30 Thread Laurent Daudelin
On Jun 30, 2010, at 17:48, Greg Parker wrote:

 On Jun 30, 2010, at 2:42 PM, Laurent Daudelin wrote:
 Yes, I know that, but can you send an instance method to a class object?
 
 Yes, you can. Every class object is itself an instance of NSObject. 
 Therefore, every class object also responds to all of NSObject's instance 
 methods. 
 
 http://sealiesoftware.com/blog/archive/2009/04/14/objc_explain_Classes_and_metaclasses.html
 
 (Pedantically, every class object is itself an instance of its root class. 
 But to a close approximation that root class is always NSObject.)
 

Thanks, Greg. I guess you learn something new every day. I've never had to 
check if a class object responded to a selector before but now that's good to 
know! Going back to my code now...

-Laurent.
-- 
Laurent Daudelin
AIM/iChat/Skype:LaurentDaudelin 
http://www.nemesys-soft.com/
Logiciels Nemesys Software  
laur...@nemesys-soft.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: NSString ambiguities

2010-06-30 Thread Douglas Davidson

On Jun 30, 2010, at 3:02 PM, Ariel Feinerman wrote:

 If we read whole file as a NSString, will be any conversions between \r\n,
 \r, \n? Then if not, will be -componentsSeparatedByCharactersInSet:
 [NSCharacterSet newlineCharacterSet] create empty strings in Win \r\n case?
 So what is the best: [NSCharacterSet newlineCharacterSet] or [NSCharacterSet
 characterSetWithCharactersInString: @\n] or simply
 -componentsSeparatedByString: @\n?

What's best is enumerateSubstringsInRange:options:usingBlock:.  You can use 
NSStringEnumerationByParagraphs to handle all the standard paragraph 
separators.  Prior to 10.6, use paragraphRangeForRange: or 
getParagraphStart:end:contentsEnd:forRange: and construct your own loop.

Douglas Davidson___

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


configurePersistentStoreCoordinatorForURL:ofType: modelConfiguration: storeOptions:error

2010-06-30 Thread Chris Idou


According to the doco, the above method is used to customise creation of the 
persistent store especially with regards to the store type. So I've been using 
the below code, which works perfectly fine for NSBinaryStoreType and 
NSXMLStoreType, but with NSSQLiteStoreType I get lots of merge errors when 
saving documents that I don't get if I completely remove the below code and let 
the framework handle it. Apparently I'm doing something subtlety wrong. Does 
anyone know what? At times like this I wish Apple would make their source code 
visible to developers.




- (BOOL)configurePersistentStoreCoordinatorForURL:(NSURL *)url ofType:(NSString 
*)fileType modelConfiguration:(NSString *)configuration 
storeOptions:(NSDictionary *)storeOptions error:(NSError **)error; {
if(![[[selfmanagedObjectContext] persistentStoreCoordinator] 
addPersistentStoreWithType:NSSQLiteStoreTypeconfiguration:nilURL:url 
options:[NSDictionarydictionaryWithObjectsAndKeys:[NSNumbernumberWithBool:YES], 
NSMigratePersistentStoresAutomaticallyOption, [NSNumbernumberWithBool:YES], 
NSInferMappingModelAutomaticallyOption, nil] error:error]){
[[NSApplicationsharedApplication] presentError:*error];
returnNO;
} else {
returnYES;
}
}



___

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 revert to an unedited document window?

2010-06-30 Thread Brad Stone
That was the suggestion I needed.  Thank you.  Here's what I did in the 
windowControler:

[doc removeWindowController:self];
[[self managedObjectContext] rollback];
[doc close];

and then I use my normal routine to reload the document. 

On Jun 29, 2010, at 12:23 PM, Jerry Krinock wrote:

 
 On 2010 Jun 29, at 05:23, Brad Stone wrote:
 
 Using [NSPersistentDocument revertToContentsOfURL:(NSURL 
 *)inAbsoluteURLofType:(NSString *)inTypeName error:(NSError**)outError] 
 works except the window closes and opens.  If that didn't happen I'd be fine.
 
 Reverting a Core Data document is tricky.  Apple's recommended methods are 
 given here:
 
 http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/NSPersistentDocumentTutorial/04_Department/department.html#//apple_ref/doc/uid/TP40002832-SW6
 
 But you should also read these:
 
 http://www.cocoabuilder.com/archive/cocoa/161579-bug-in-nspersistentdocument-tutorial.html#161579
 http://www.cocoabuilder.com/archive/cocoa/174292-bug-nspersistentdocument-core-data-tutorial.html#174292
 http://www.cocoabuilder.com/archive/cocoa/177523-bug-nspersistentdocument-core-data-tutorial.html#177523
 
 Since Revert is not a major advertised feature of the app I was working on, 
 after trying unsuccessfully to make it work for an hour or so,  I gave up and 
 implemented Revert to simply close and re-open the document.  It's a little 
 slow and ugly, but it works, and eliminates a branch of regression 
 possibilities.
 
 ___
 
 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/cocoa-dev%40softraph.com
 
 This email sent to cocoa-...@softraph.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: configurePersistentStoreCoordinatorForURL:ofType: modelConfiguration: storeOptions:error

2010-06-30 Thread Jerry Krinock

On 2010 Jun 30, at 16:42, Chris Idou wrote:

 According to the doco, the above method is used to customise creation of the 
 persistent store especially with regards to the store type.

In my documentation, it's a little different:  Configures the receiver’s 
persistent store coordinator with the appropriate stores for a given URL.

 So I've been using the below code, which works perfectly fine for 
 NSBinaryStoreType and NSXMLStoreType, but with NSSQLiteStoreType I get lots 
 of merge errors when saving documents that I don't get if I completely remove 
 the below code and let the framework handle it. Apparently I'm doing 
 something subtlety wrong. Does anyone know what?

Not subtle.  Apparently, adding a persistent store as you're doing is not 
sufficient to configure an sqlite store, whatever Apple means by that.  I'm 
not surprised!  Try invoking super.  More specifically, since it appears that 
all you want to do is add a couple of key/value pairs to the store options, do 
an internet search for mmalc's MigratingDepartmentAndEmployees Sample Code and 
override that method like he does.

 At times like this I wish Apple would make their source code visible to 
 developers.

That may have been helpful ten years ago (and the GNUStep source is still 
around).  But in the case of Core Data, I suspect that taking time out to sift 
through Apple's source code would not be very productive :))

___

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