Re: Getting other application's window/document name

2009-05-21 Thread Eric Schlegel


On May 21, 2009, at 11:32 PM, John Ku wrote:


I should have been more specific in the question sorry.
And you are right, just tried this with Adobe Photoshop and gave me  
at least twenty entries for photoshop's floating windows and  
palettes and others like spotlight, systemUI Server. With background  
processes, I could probably match it against with what I get from  
NSWorkspace/LaunchedApplication, but the palettes and inspectors are  
there. Too trigger happy on my part. :P


Perhaps there is a tricky way to filter it, all I need is to get  
only the launched Applications and their window/document if any. Any  
ideas?


Depending on exactly what your purpose is in gathering this info, you  
might also be able to use the Accessibility API to get the AXDocument  
attribute of the window. That will be the path to the on-disk document  
represented by the window. That won't help in cases where the window  
has no on-disk document, however.


-eric

___

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: Compiler does not synthesize KVO compliant properties for CATiledLayer subclass (was: Synthesized properties for scalars not KVO compliant)

2009-05-21 Thread Kiel Gillard

Hi Dave,

On 22/05/2009, at 4:12 PM, Dave Keck wrote:


Hello,

A few days ago I was having this same issue. The reason KVO doesn't
work out-of-the-box with CALayer subclasses, I believe, is because
CALayer overrides +automaticallyNotifiesObserversForKey: to return NO.
My solution was to override +aNOFK: in my custom subclass to return
YES for my custom key. This has worked flawlessly for me - please let
me/us know whether it does for you.


Thanks! This seems to be a solution to the problem.


Here's the applicable code
snippet:

+ (BOOL)automaticallyNotifiesObserversForKey: (NSString *)key
{

   /* The NSObject implementation defaults to returning YES to this
method. But because we're a CALayer subclass,
  we have to override it to return YES when key == one of our
properties. This is because CALayer overrides the
  NSObject default functionality, so that this method always
returns NO for CALayer and its subclasses. */

   if ([key isEqualToString: @"gridShown"])
   return YES;

   return [super automaticallyNotifiesObserversForKey: key];

}


It would be great if we could get a reason as to why it seems to  
always return NO. My guess would be that there could be a significant  
performance overhead using the KVO mechanism for every layer's property?



(I suppose we could figure out definitively whether CALayer was
overriding +aNOFK: by comparing its +aNOFK: IMP with NSObject's
+aNOFK: IMP. If I try this I'll get back to the list with my
findings...)

David


Thanks David, that'd be great!

Kiel
___

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: Getting other application's window/document name

2009-05-21 Thread John Ku
I should have been more specific in the question sorry.And you are right,
just tried this with Adobe Photoshop and gave me at least twenty entries for
photoshop's floating windows and palettes and others like spotlight,
systemUI Server. With background processes, I could probably match it
against with what I get from NSWorkspace/LaunchedApplication, but the
palettes and inspectors are there. Too trigger happy on my part. :P

Perhaps there is a tricky way to filter it, all I need is to get only the
launched Applications and their window/document if any. Any ideas?

Cheer,
John Ku

On Thu, May 21, 2009 at 11:14 PM, Kyle Sluder  wrote:

> On Fri, May 22, 2009 at 1:43 AM, John Ku  wrote:
> > Fantastic, this is exactly what Im looking for. Time to dive into C!
>
> This is not going to get you the names of documents, it will get you
> the titles of windows.  You have no idea whether a window is a
> document window, inspector, or other some other kind of window, and
> you have no idea what the relationship is between the window title and
> the document name.
>
> It is far from exactly what you were asking for.
>
> --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: Best way to draw text in CAOpenGLLayer

2009-05-21 Thread Anshul jain

HI
	thanks for suggestion. Since i want to scroll the text so i have to  
update it regularly so i have taken a CAOPenGLLayer and set is  
asynchronous and  i am using



 - (void)drawInCGLContext:(CGLContextObj)glContext pixelFormat: 
(CGLPixelFormatObj)pixelFormat forLayerTime: 
(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp *)timeStamp



this fuction to update text.

Is this the right approach to do it.



On 21-May-09, at 10:52 PM, David Duncan wrote:


On May 21, 2009, at 10:12 AM, David Duncan wrote:

Don't. Use a CATextLayer (which can render text for you) or a  
CALayer (to display image content) instead. Unless you want to get  
outlines of your text, the CAOpenGLLayer is really not a good way  
to do this.



Clarifying a bit - unless you want to render your text as vector  
graphics, then you don't want to use an OpenGL layer to do this.

--
David Duncan
Apple DTS Animation and Printing




Regards,
Anshul jain
Software Engineer

Prithvi Information Solutions Ltd
10Q3A1, Cyber Towers
HITEC City, Madhapur
Hyderabad - 500 081





___

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 draw text in CAOpenGLLayer

2009-05-21 Thread Anshul jain

HI
	thanks for suggestion. Since i want to scroll the text so i have to  
update it regularly so i have taken a CAOPenGLLayer and set is  
asynchronous and  i am using



 - (void)drawInCGLContext:(CGLContextObj)glContext pixelFormat: 
(CGLPixelFormatObj)pixelFormat forLayerTime: 
(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp *)timeStamp



this fuction to update text.

Is this the right approach to do it.



On 21-May-09, at 10:52 PM, David Duncan wrote:


On May 21, 2009, at 10:12 AM, David Duncan wrote:

Don't. Use a CATextLayer (which can render text for you) or a  
CALayer (to display image content) instead. Unless you want to get  
outlines of your text, the CAOpenGLLayer is really not a good way  
to do this.



Clarifying a bit - unless you want to render your text as vector  
graphics, then you don't want to use an OpenGL layer to do this.

--
David Duncan
Apple DTS Animation and Printing







Regards,
Anshul jain




___

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: Getting other application's window/document name

2009-05-21 Thread Kyle Sluder
On Fri, May 22, 2009 at 1:43 AM, John Ku  wrote:
> Fantastic, this is exactly what Im looking for. Time to dive into C!

This is not going to get you the names of documents, it will get you
the titles of windows.  You have no idea whether a window is a
document window, inspector, or other some other kind of window, and
you have no idea what the relationship is between the window title and
the document name.

It is far from exactly what you were asking for.

--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: Compiler does not synthesize KVO compliant properties for CATiledLayer subclass (was: Synthesized properties for scalars not KVO compliant)

2009-05-21 Thread Dave Keck
Hello,

A few days ago I was having this same issue. The reason KVO doesn't
work out-of-the-box with CALayer subclasses, I believe, is because
CALayer overrides +automaticallyNotifiesObserversForKey: to return NO.
My solution was to override +aNOFK: in my custom subclass to return
YES for my custom key. This has worked flawlessly for me - please let
me/us know whether it does for you. Here's the applicable code
snippet:

+ (BOOL)automaticallyNotifiesObserversForKey: (NSString *)key
{

/* The NSObject implementation defaults to returning YES to this
method. But because we're a CALayer subclass,
   we have to override it to return YES when key == one of our
properties. This is because CALayer overrides the
   NSObject default functionality, so that this method always
returns NO for CALayer and its subclasses. */

if ([key isEqualToString: @"gridShown"])
return YES;

return [super automaticallyNotifiesObserversForKey: key];

}

(I suppose we could figure out definitively whether CALayer was
overriding +aNOFK: by comparing its +aNOFK: IMP with NSObject's
+aNOFK: IMP. If I try this I'll get back to the list with my
findings...)

David
___

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: [Core Data] Difference between objectWithID: and a fetch "self IN %@", someObjectIDs ????

2009-05-21 Thread Aurélien Hugelé


That's very clear, thanks for the explanation!

Aurélien,
Objective Decision Team




On 20 mai 09, at 21:15, Ben Trumbull wrote:


In the main thread, using objectWithID: repeatedly on each objectID
sent by the subthread returns the object that was inserted in the
background thread. This is exactly what I want.
But reading from the doc, it seems that we are encouraged to use a
fetch using "self IN %@",listOfObjectIDs instead of objectWithID:
since it is faster for many objects...

Unfortunately, this fetch returns 0 results (and yes this is the
correct entity, store and moc...)


The objects probably haven't been saved yet.


what does objectWithID: *exactly* do that a fetch does not ??


Imagine the NSPersistentStoreCoordinator has a cache of row data for  
recently fetched or saved objects.  This cache is used to fulfill  
faults quickly.  Faulting becomes very slow when it needs to go all  
the way to the database due to a cache miss.  The Core Data template  
in Instruments shows this.


But cache hits are very fast.  This is how most managed objects get  
initialized.


Fetching always goes to disk and gets the latest values from the  
database.  Those values are then added to the PSC's cache.


-objectWithID: creates a fault.  When you access the fault's data,  
it first tries to populate the data from the PSC's cache.  If it  
can't, then it goes to disk.


The documentation is showing how to load a number of objects at  
once.  If the objects are unlikely to already be cached, then  
fetching all of them in 1 transaction will be much faster than  
faulting them in one at a time via -objectWithID:


- Ben



___

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: Getting other application's window/document name

2009-05-21 Thread John Ku
Fantastic, this is exactly what Im looking for. Time to dive into C!

Thanks!!

On Thu, May 21, 2009 at 10:24 PM, Eric Schlegel  wrote:

>
> On May 21, 2009, at 12:59 AM, John Ku wrote:
>
>  What should I look into if I need to grab the document/window name from
>> other running applications? Currently I have the following to get a list
>> of
>> available running applications:
>> [[NSWorkspace sharedWorkspace] launchedApplication]
>>
>> How do I go about getting the document/window name from other
>> applications?
>>
>
> On Leopard and later, you may be able to do this with the CGWindow API
> (CGWindow.h). Something like this:
>
> - use CGWindowListCreate to get a list of all windows
> - for each window in the list, use CGWindowListCopyWindowInfo to get info
> about the window
> - from each window's info, get the kCGWindowOwnerPID entry so you can sort
> windows by pid
> - from each window's info, get the kCGWindowName entry so you can identify
> the window name
>
> -eric
>
>
___

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: Getting other application's window/document name

2009-05-21 Thread Eric Schlegel


On May 21, 2009, at 12:59 AM, John Ku wrote:

What should I look into if I need to grab the document/window name  
from
other running applications? Currently I have the following to get a  
list of

available running applications:
[[NSWorkspace sharedWorkspace] launchedApplication]

How do I go about getting the document/window name from other  
applications?


On Leopard and later, you may be able to do this with the CGWindow API  
(CGWindow.h). Something like this:


- use CGWindowListCreate to get a list of all windows
- for each window in the list, use CGWindowListCopyWindowInfo to get  
info about the window
- from each window's info, get the kCGWindowOwnerPID entry so you can  
sort windows by pid
- from each window's info, get the kCGWindowName entry so you can  
identify the window name


-eric

___

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 set dpi of an image

2009-05-21 Thread Graham Cox


On 22/05/2009, at 2:48 PM, Mahaboob wrote:



I gone through that links and I can't figure it out how to set the  
dpi.

By googling I found a function to set dpi in windows :

public RenderTargetBitmap(
   int pixelWidth,
   int pixelHeight,
   double dpiX,
   double dpiY,
   PixelFormat pixelFormat
)

Is there any equivalent method?
Is it my size calculation is right?



dpi is just the ratio between an image's size and the pixels it  
contains.


If it helps, here's a method from DrawKit that takes a pdf image and  
returns a bitmap of it at any desired dpi. It's a category method on  
an object returns a pdf representation of itself (ultimately by  
calling NSView's -dataWithPDFInsideRect: method). I start with a pdf  
because it can be rasterized to any dpi with maximum quality.


- (CGImageRef)			CGImageWithResolution:(int) dpi hasAlpha:(BOOL)  
hasAlpha relativeScale:(float) relScale


{
NSPDFImageRep* pdfRep = [NSPDFImageRep imageRepWithData:[self pdf]];

NSAssert( pdfRep != nil, @"couldn't create pdf image rep");
NSAssert( relScale > 0, @"scale factor must be greater than zero");

if( pdfRep == nil )
return nil;

// create a bitmap rep of the requisite size.

NSSize  bmSize = [self drawingSize];

bmSize.width = ceil(( bmSize.width * (float)dpi * relScale ) / 72.0f );
	bmSize.height = ceil(( bmSize.height * (float)dpi * relScale ) /  
72.0f );


NSBitmapImageRep* bmRep;

bmRep = [[NSBitmapImageRep alloc]   initWithBitmapDataPlanes:NULL

pixelsWide:bmSize.width

pixelsHigh:bmSize.height

bitsPerSample:8

samplesPerPixel:4

hasAlpha:YES

isPlanar:NO

colorSpaceName:NSCalibratedRGBColorSpace

bytesPerRow:0

bitsPerPixel:0];

NSAssert( bmRep != nil, @"couldn't create bitmap for export");

if( bmRep == nil )
return nil;

	//LogEvent_( kInfoEvent, @"size = %@, dpi = %d, rep = %@",  
NSStringFromSize( bmSize ), dpi, bmRep );


	NSGraphicsContext* context = [NSGraphicsContext  
graphicsContextWithBitmapImageRep:bmRep];

[bmRep release];

[NSGraphicsContext saveGraphicsState];
[NSGraphicsContext setCurrentContext:context];

[context setShouldAntialias:YES];
[context setImageInterpolation:NSImageInterpolationHigh];

NSRect destRect = NSZeroRect;
destRect.size = bmSize;

// if not preserving alpha, paint the background in the paper colour

if ( !hasAlpha )
{
[[self paperColour] set];
NSRectFill( destRect );
}

// draw the PDF rep into the bitmap rep.

[pdfRep drawInRect:destRect];

[NSGraphicsContext restoreGraphicsState];

CGImageRef  image = CGBitmapContextCreateImage([context 
graphicsPort]);

return (CGImageRef)[(NSObject*)image autorelease];
}



--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: How to set dpi of an image

2009-05-21 Thread Mahaboob

I gone through that links and I can't figure it out how to set the dpi.
By googling I found a function to set dpi in windows :

public RenderTargetBitmap(
int pixelWidth,
int pixelHeight,
double dpiX,
double dpiY,
PixelFormat pixelFormat
)

Is there any equivalent method?
Is it my size calculation is right?


On 5/21/09 2:09 PM, "jonat...@mugginsoft.com" 
wrote:

> 
> On 21 May 2009, at 08:29, Mahaboob wrote:
> 
>> I need to save the image with respect to the given dpi.
>> I calculated the image size proportional to the dpi and saved it.
>> But when I'm viewing the dpi from preview it shows only 72 dpi.
>> 
>> I used the code like:
>> 
>> float compressionFactor = [compressionSlider floatValue];
>> 
>> NSDictionary *jpegProperties = [NSDictionary dictionaryWithObject:
>> [NSNumber
>> numberWithFloat: compressionFactor] forKey: NSImageCompressionFactor];
>> 
>>NSSize size = [image size];
>> 
>>unsigned int resfac =  (unsigned int)[bitmapResolution
>> intValue];
>> 
>> 
>> 
>>[image setScalesWhenResized:YES];
>> 
>> 
>> 
>>[image setSize:NSMakeSize(size.width * resfac/72, size.height *
>> resfac/72)];
>> 
> setSize: doesn't change the underlying image reps
> see the docs 
> http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaDrawingGuide/Im
> ages/Images.html#/
> /apple_ref/doc/uid/TP40003290-CH208-SW2
> 
> or this http://weblog.scifihifi.com/2005/06/25/how-to-resize-an-nsimage/
> 
> Apple has some decent sample code with CoreImage additions here
> http://developer.apple.com/SampleCode/Reducer/listing16.html
> 
>> 
>>NSBitmapImageRep *theBmapRep = [NSBitmapImageRep imageRepWithData:
>> [image
>> TIFFRepresentation]];
>> 
>> NSData *exportedData;
>> 
>> exportedData = [ theBmapRep representationUsingType:NSJPEGFileType
>> properties:jpegProperties];
>> 
>> Is it I'm missing something?
>> How can I set the exact dpi?
>> 
>> Thanks in advance
>> Mahaboob
>> 
>> 
>> 
>> 
>> ___
>> 
>> 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/jonathan%40mugginsoft.com
>> 
>> This email sent to jonat...@mugginsoft.com
> 
> Jonathan Mitchell
> 
> Central Conscious Unit
> 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: Affine transform not being applied to subviews

2009-05-21 Thread Ken Tozier

Thanks Graham

It took a bit of trial and error, but scaleUnitSquareToSize seems to  
do what I want. I ripped out all the transform code and just wrote a  
simple override to setFrame for the page view


- (void) setFrame:(NSRect) inFrame
{
NSSize  currentSize = [self frame].size;

float   scale   = inFrame.size.height / 
currentSize.height;

[self scaleUnitSquareToSize: NSMakeSize(scale, scale)];
[super setFrame: inFrame];
}


Much easier

- Ken

On May 21, 2009, at 10:59 PM, Graham Cox wrote:



On 22/05/2009, at 12:52 PM, Ken Tozier wrote:


- (void) drawRect:(NSRect) inRect
{
NSAffineTransform   *transform  = [self transform];

[transform concat];

[[NSColor whiteColor] set];
NSRectFillUsingOperation([self frame], NSCompositeSourceOver);

[[NSColor blackColor] set];
	NSFrameRectWithWidthUsingOperation([self frame], 1,  
NSCompositeSourceOver);

}



Setting a transform in -drawRect: will only apply it to whatever is  
drawn within that method. That doesn't include the subviews.


What are you trying to do? If you need to scale the page view then  
use -scaleUnitSquareToSize: and adjust the frame. To translate use a  
scrollview. To rotate, use -rotateToAngle:


--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: Ask for NSTextField

2009-05-21 Thread Nick Zitzmann


On May 21, 2009, at 12:58 AM, star red wrote:

When a user presses a right mouse button on the NSTextField,  a  
context menu

will appear.
I want that a context menu will not appear at this time.


Why? That's really non-standard.


How can ?



The first thing I'd try is setting the text field's menu to nil. If  
that doesn't work, then subclass NSTextField and override - 
menuForEvent: to return nil.


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: Deallocating cocoa distant objects.

2009-05-21 Thread Ken Thomases

On May 21, 2009, at 4:01 PM, Santosh Sinha wrote:

I need your help with how to deallocate an object which is created  
in a server process A from a client process B.


In the project as we can see in the NSLog once the MyClass object is  
created and returned to the client, its retain count becomes 3. This  
causes the MyClass object to be refrained from getting deallocated  
even after releaseMyself is called.


Never attempt to debug memory management by inspecting retain counts.   
It will almost always lead you in the wrong direction.


For example, querying the remote object's retain count is very likely  
to give you a misleading answer.  It's very likely that the object is  
retained an additional time during the handling of the inter-process  
request... for its retain count.


But that's just one example specific to this test.  Inspecting retain  
counts is unhelpful even in the general case.  For example, if an  
object has been retained and that's been balanced by an autorelease,  
the retain count will show an "extra" (seemingly unbalanced) retain  
even though the retain has been balanced.  Etc., etc.


Use Instruments and/or logging in -dealloc to determine if objects  
really are being deallocated when (or at least soon after) you think  
they should be.



Also, in the function call setString:(MutableString**). I think I am  
doing straightforward in client by allocating it in Client, setting  
its content in Server and then deallocating it in Client after I  
have used it but the release of the allocated string in the client  
results in a crash when the local release pool is popped out.


First, why are you using double indirection in that method?  Why not  
just pass the mutable string object byref (the default) and then  
invoke -setString: on it?  (Well, of course, the simpler way of  
implementing that would be to simply request a string from the remote  
object rather than asking the remote object to modify an already  
existing string, but I assume you're presenting a simplified case for  
some other case.)


Then, there's no way for us to know why you're getting a crash when  
the autorelease pool is popped until you identify what's actually  
happening.  Is there a Cocoa exception?  If so, what exception?  Is it  
a kernel exception or signal?  If so, what?  On what object was the  
autorelease pool acting?  Who allocated it?  Have you used Instruments  
to trace the retain/release history of that object?  Have you tried  
NSZombieEnabled?


Lastly, it's very possible there are memory management bugs in  
Distributed Objects.  If you feel you've identified one, submit a bug  
report to Apple.


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


Compiler does not synthesize KVO compliant properties for CATiledLayer subclass (was: Synthesized properties for scalars not KVO compliant)

2009-05-21 Thread Kiel Gillard

Hi all,

Thanks for your suggestions and help so far.

I believe my problem is that my model object is a subclass of  
CATiledLayer. Synthesized accessor methods for the CATiledLayer  
subclass are not key value observing compliant. Yet, by changing the  
immediate superclass of the model object to NSObject, the synthesized  
accessor methods are KVO compliant. Any ideas what I can do besides  
provide my own accessor methods?


Below I have some code for a Cocoa Application template in Xcode. I  
have an optional #define INHERITS_FROM_NSOBJECT. I have two custom  
classes, Controller (inheriting from NSObject) and CustomLayer  
(inheriting from CATiledLayer or NSObject). CustomLayer inherits from  
NSObject if INHERITS_FROM_NSOBJECT has been #define'd.


In the XIB I have a top level instance of Controller. It contains an  
outlet pointing to the content view of the XIB's window.


Thanks again!

Kiel

//#define INHERIT_FROM_NSOBJECT 1

#ifdef INHERIT_FROM_NSOBJECT
@interface CustomLayer : NSObject {
#else
@interface CustomLayer : CATiledLayer {
#endif
CGFloat ivar1;
CGFloat ivar2;
NSString *stringIvar;
}

@property CGFloat ivar1;
@property CGFloat ivar2;
@property (retain, nonatomic) NSString *stringIvar;
@end

@implementation CustomLayer

- (id)init
{
if (self = [super init]) {
self.ivar1 = 1.0;
self.ivar2 = 1.0;
#ifndef INHERIT_FROM_NSOBJECT
self.bounds = CGRectMake(0.0, 0.0, 2000.0, 2000.0);
self.backgroundColor = CGColorGetConstantColor(kCGColorBlack);
#endif
self.stringIvar = @"String ivar";

		NSLog(@"Created layer %@ with ivar1 == %f, ivar2 == %f, stringIvar  
== %@", self, self.ivar1, self.ivar2, self.stringIvar);

}

return self;
}

- (void)dealloc
{
self.stringIvar = nil;
[super dealloc];
}

@synthesize ivar1;
@synthesize ivar2;
@synthesize stringIvar;
@end


@interface Controller : NSObject {
IBOutlet NSView *view;
}

@end

#import "Controller.h"
#import "CustomLayer.h"

static NSUInteger IvarChange, StringIvarChange;

@implementation Controller

- (void)awakeFromNib
{
[view setWantsLayer:YES];

//create catiledlayer or nsobject subclass with observed properties
CustomLayer *layer = [[[CustomLayer alloc] init] autorelease];
	[layer addObserver:self forKeyPath:@"ivar1" options:0  
context:&IvarChange];
	[layer addObserver:self forKeyPath:@"ivar2" options:0  
context:&IvarChange];
	[layer addObserver:self forKeyPath:@"stringIvar" options:0  
context:&StringIvarChange];


#ifdef INHERIT_FROM_NSOBJECT
//leak memory deliberately for the sake of the example
[layer retain];
#else
	//add layer as a sublayer to force the CoreAnimation machinery to use  
the tiled layer subclass

[[view layer] addSublayer:layer];
#endif

//setup a timer to modify the properties of the layer object
	NSDictionary *userInfo = [NSDictionary  
dictionaryWithObjectsAndKeys:layer, @"layer", nil];
	[NSTimer scheduledTimerWithTimeInterval:1.5 target:self  
selector:@selector(timerDidFire:) userInfo:userInfo repeats:YES];

}

- (void)timerDidFire:(NSTimer *)timer
{
NSDictionary *userInfo = [timer userInfo];
CustomLayer *layer = [userInfo valueForKey:@"layer"];

	NSLog(@"Manipulating ivar1 (%f) and ivar2 (%f) of layer %@",  
layer.ivar1, layer.ivar2, layer);

layer.ivar1 = layer.ivar1 + 1.0;
layer.ivar2 = layer.ivar2 + 1.0;
	NSLog(@"Manipulated ivar1 (%f) and ivar2 (%f) of layer %@",  
layer.ivar1, layer.ivar2, layer);


NSLog(@"Manipulating string ivar (%@)", layer.stringIvar);
layer.stringIvar = [[NSDate date] description];
NSLog(@"Manipulated string ivar (%@)\n\n", layer.stringIvar);
}

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object  
change:(NSDictionary *)change context:(void *)context

{
NSLog(@"%...@.%@ == %@", object, keyPath, [object valueForKey:keyPath]);

if (context == &IvarChange) {
NSLog(@"Float ivar change");

} else if (context == &StringIvarChange) {
NSLog(@"String ivar change");

} else {
		[super observeValueForKeyPath:keyPath ofObject:object change:change  
context:context];

}
}

@end

On 20/05/2009, at 10:45 AM, Jerry Krinock wrote:



On 2009 May 19, at 16:52, Kiel Gillard wrote:

I feel I may be missing something very simple but I have no idea  
what.


Never tried it with structs like CGRect but I just bound some  
integers like this yesterday and they KVO works.  The title of your  
message says "not KVO compliant".  Please clarify: Is the console  
log telling you this, or is this your interpretation?



Any suggestions?


Post some code.

___

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

Please do not

Re: What's the differnece between API and Framework?

2009-05-21 Thread Gunnar Proppe

There are also multiple definitions of "framework."

Here's Apple's definition:
http://developer.apple.com/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WhatAreFrameworks.html
"A framework is a hierarchical directory that encapsulates shared resources, 
such as a dynamic shared library, nib files, image files, localized strings, 
header files, and reference documentation in a single package. Multiple 
applications can use all of these resources simultaneously. The system loads 
them into memory as needed and shares the one copy of the resource among all 
applications whenever possible."

In the Finder, go to /System/Library/Frameworks. There, you'll find a bunch of 
directories that end in ".framework". For example, CoreAudio.framework. These 
are the frameworks the above definition refers to.


In the wider software development world, however, the term "framework" has 
additional nuance:
http://en.wikipedia.org/wiki/Software_framework
"A software framework, in computer programming, is an abstraction in which 
common code providing generic functionality can be selectively overridden or 
specialized by user code providing specific functionality.
Frameworks are similar to software libraries in that they are reuseable 
abstractions of code wrapped in a well-defined API. Unlike libraries, however, 
the overall program's flow of control is not dictated by the caller, but by the 
framework. This inversion of control is the distinguishing feature of software 
frameworks."

In this definition, a framework is like a machine that you can plug your custom 
gears into, while a library is like a box of Legos that you can build stuff out 
of one block at a time.

Cocoa is a framework in both the Mac-specific sense, and the wider, computer 
science sense.

Here's where it gets potentially confusing: some Mac frameworks fit the 
machine/gears metaphor and some fit the Legos metaphor.

As others have said, an API is the "menu" or "blueprint" for how your code 
should use a framework or set of libraries.

Gunnar

- Original Message 
> From: Chunk 1978 
> To: cocoa-dev Dev 
> Sent: Thursday, May 21, 2009 6:38:45 PM
> Subject: Re: What's the differnece between API and Framework?
> 
> ok... so an API is like a lower level framework?  wikipedia states
> that Carbon and Cocoa are APIs on Mac, but i always thought those were
> frameworks.
> 
> On Thu, May 21, 2009 at 8:50 PM, Jonathan Hess wrote:
> > An API is a set of functions, classes, methods, and other bits that give you
> > a method to interface with a piece of software. A framework is one concrete
> > way to package a body of software with a set of header files that describe
> > its API. A web service is another way to give clients an API to a set of
> > software functionality that exists on a far away server.
> >
> > So, you might think of a framework as one of many methods of delivering a
> > package of software with an API.
> >
> > Jon Hess
> >
> > On May 21, 2009, at 5:33 PM, Chunk 1978 wrote:
> >
> >> my learning is still shady on what is actually an API... sounds like a
> >> framework to me... ?
> >> ___
> >>
> >> 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/jhess%40apple.com
> >>
> >> This email sent to jh...@apple.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/tonecluster%40yahoo.com
> 
> This email sent to toneclus...@yahoo.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: Getting other application's window/document name

2009-05-21 Thread Kyle Sluder
On Thu, May 21, 2009 at 3:59 AM, John Ku  wrote:
> How do I go about getting the document/window name from other applications?

Unless the developers of the application have explicitly provided an
API with which to do so (the most common one is AppleScript) then you
can't do it.  As far as your app is concerned, other processes are
simply black boxes.

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


How to use CFReadStrem and abort read stream normally?

2009-05-21 Thread Chris Gardner

Hi,
I have already read through CFReadStream archives, and still have trouble with 
it.
After CFReadStreamOpen() has been implement and its status is 
kCFStreamEventHasBytesAvailable,
so I can read data from the source.Of course, there's no problem. As for the 
FTP server, 
I can connect it by using CFReadStreamCreateWithFTPURL.
Now, I would like to abort/disconnect the read stream when its status is 
kCFStreamEventHasBytesAvailable.
At that time. I will use CFReadStreamClose() and CFRunLoopStop(). 
As you know, the read stream was availabe in a run loop 
where data stream can tranfer from FTP server to destination.
However, I met a terrible problem which show GDB:Program received 
signal:"EXC_BAD_ACCESS" as soon as I do above operation,
also I see the read stream's status become kCFStreamEventErrorOccurred.
So my question is...How can I avoid this error and how can I abort the read 
stream normally 
when its status is kCFStreamEventHasBytesAvailable.
Your help will be appreciated.
Best Regards.
Chris Wu
_
More than messages–check out the rest of the Windows Live™.
http://www.microsoft.com/windows/windowslive/___

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


Deallocating cocoa distant objects.

2009-05-21 Thread Santosh Sinha

Hi List.

I need your help with how to deallocate an object which is created in  
a server process A from a client process B.


In the project as we can see in the NSLog once the MyClass object is  
created and returned to the client, its retain count becomes 3. This  
causes the MyClass object to be refrained from getting deallocated  
even after releaseMyself is called.


Also, in the function call setString:(MutableString**). I think I am  
doing straightforward in client by allocating it in Client, setting  
its content in Server and then deallocating it in Client after I have  
used it but the release of the allocated string in the client results  
in a crash when the local release pool is popped out.



Thanks
Santosh

// 
***

//Protocols.h
@protocol ICServer  
-(HRESULT) createmMyClass:(id *)outInterface;
@end

@protocol IMyClass  
-(HRESULT) releaseMyself;
-(HRESULT) getRetainCount:(long*)outRetainCount;
-(HRESULT) setString:(NSMutableString**)outString;
@end

// 
***

Client Code:

//  Client.h
#import 
#import 
#import "Protocols.h"
@interface Client : NSObject {
id  m_MyClassObj;
id m_RemoteObjectProxy;}
-(void) testRemoteObject;
-(void) deleteMyClass;
@end

// 
***

//  Client.m
#import "Client.h"
@implementation Client
- (id) init{
if (self = [super init]){
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
m_RemoteObjectProxy = nil;
m_MyClassObj = nil;
if(!m_RemoteObjectProxy){
			m_RemoteObjectProxy = [[NSConnection  
rootProxyForConnectionWithRegisteredName: IDS_SERVER_CXINPROC host:  
nil] retain];

[m_RemoteObjectProxy 
setProtocolForProxy:@protocol(ICServer)];}
if(nil == m_RemoteObjectProxy){ 

NSLog(@"Error registering with server");}
else{
NSLog(@"Connection with server is successfully 
established.");}
[pool release];}
return self;}

-(void) dealloc{
if (m_RemoteObjectProxy)
[m_RemoteObjectProxy release];
[super dealloc];}

-(void) testRemoteObject{
HRESULT hRes = E_FAIL;
long retainCt = -1;
NSMutableString* str = [[NSMutableString alloc] init];
NSMutableString* myStr = [[NSMutableString alloc] init];
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
if (m_RemoteObjectProxy)
hRes = [m_RemoteObjectProxy createmMyClass:&m_MyClassObj];
if ( !SUCCEEDED(hRes) )
[str setString:@"\n0 Myclass objects created."];
else{
hRes = [m_MyClassObj getRetainCount:&retainCt];
if (SUCCEEDED(hRes))
			[str appendString:[NSString stringWithFormat:@"\nRetainCount of  
Myclass is %d",retainCt]];

else
[str appendString:@"\nRetain count of Myclass is not 
obtained"];
hRes = [m_MyClassObj setString:&myStr];
if (SUCCEEDED(hRes))
			[str appendString:[NSString stringWithFormat:@"\nString is set in  
server with %@",myStr]];		}

[str release];
[pool release];}

-(void) deleteMyClass{
HRESULT hRes = E_FAIL;
long retainCt = -1;
NSMutableString* str = [[NSMutableString alloc] init];
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
if (m_RemoteObjectProxy){
if (m_MyClassObj){
hRes = [m_MyClassObj releaseMyself];
if (SUCCEEDED(hRes)){
[str appendString:@"\n Myclass object deleted 
successfully"];}
else
[str appendString:@"Error in deleting Myclass 
object"];}}
[str release];  
[pool release];}
@end

// 
***

//  main.m
#import 
#import "Client.h"
int main(int argc, char *argv[]){
Client* client = [[Client alloc] init];
[client testRemoteObject];
[client deleteMyClass];
[client testR

Merge 2 QTTracks in a QTMovie

2009-05-21 Thread Alex Bumbu

Hi all,

I'm trying to add 2 sounds tracks in a QTMovie so they play at the same 
time. I've tried adding both sound tracks with the layer property 
changed to the qtmovie but the tracks are played one after another. Is 
this possible? And if is possible any help is really appreciated.


Thanks in advance,
Alex
___

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


Getting other application's window/document name

2009-05-21 Thread John Ku
What should I look into if I need to grab the document/window name from
other running applications? Currently I have the following to get a list of
available running applications:
[[NSWorkspace sharedWorkspace] launchedApplication]

How do I go about getting the document/window name from other applications?


Cheers,
John
___

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


Ask for NSTextField

2009-05-21 Thread star red
Hi, friends !
When a user presses a right mouse button on the NSTextField,  a context menu
will appear.
I want that a context menu will not appear at this time.
How can ?
Give me sample code, please.
Help m !!!
SoS!!!
___

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: Affine transform not being applied to subviews

2009-05-21 Thread Kyle Sluder
On Thu, May 21, 2009 at 10:52 PM, Ken Tozier  wrote:
> Perhaps I'm not understanding how transforms are supposed to work, but from
> my reading of the relevant drawing and transform documentation, I got the
> impression that if a transform was applied to a view, it treated the view
> and all it's subviews as a single unit. Is that not the case?

There's no reason to assume that a superview's -drawRect will be
called before a subview's -drawRect, and even if there were there's no
guarantee that the framework doesn't call -[NSGraphicsContext
saveGraphicsState] before and -[NSGraphicsContext
restoreGraphicsState] afterwards.  This is especially true when AppKit
optimizes away a superview draw when a subview that returns YES from
-isOpaque completely obscures the superview.

If you want to apply scaling to your subviews, you need to use the
frame and bounds rectangles appropriately or communicate your
transformation matrices to your subviews as you are currently doing.

--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: Affine transform not being applied to subviews

2009-05-21 Thread Graham Cox


On 22/05/2009, at 12:52 PM, Ken Tozier wrote:


- (void) drawRect:(NSRect) inRect
{
NSAffineTransform   *transform  = [self transform];

[transform concat];

[[NSColor whiteColor] set];
NSRectFillUsingOperation([self frame], NSCompositeSourceOver);

[[NSColor blackColor] set];
	NSFrameRectWithWidthUsingOperation([self frame], 1,  
NSCompositeSourceOver);

}



Setting a transform in -drawRect: will only apply it to whatever is  
drawn within that method. That doesn't include the subviews.


What are you trying to do? If you need to scale the page view then use  
-scaleUnitSquareToSize: and adjust the frame. To translate use a  
scrollview. To rotate, use -rotateToAngle:


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


Affine transform not being applied to subviews

2009-05-21 Thread Ken Tozier

Hi

I wrote a custom view that contains several other views and am having  
problems when applying an affine transform to the main view. The main  
view is a page and the two subviews are a crop view that displays page  
margins and a column view that displays the page columns. I've checked  
to make sure that the subviews are in fact children of the main view  
and they definitely are. What it happening is that the page view  
scales correctly but the subviews are drawing at their actual size.


Perhaps I'm not understanding how transforms are supposed to work, but  
from my reading of the relevant drawing and transform documentation, I  
got the impression that if a transform was applied to a view, it  
treated the view and all it's subviews as a single unit. Is that not  
the case?


Here's the code

This inits my custom document object

- (id) initWithModel:(PMXDocumentModel *) inModel
{
self = [super init];
if (self)
{
		NSUInteger		windowMask			= NSTitledWindowMask | NSClosableWindowMask  
| NSMiniaturizableWindowMask | NSResizableWindowMask,
		pasteboardMask		= NSViewWidthSizable | NSViewHeightSizable |  
NSViewMinXMargin | NSViewMaxXMargin | NSViewMinYMargin |  
NSViewMaxYMargin;


		PMXPageModel	*pageModel			= [PMXPageModel pageModelWithDocument:  
inModel];

PMXPageView *pageView;

NSRect  defaultFrame= 
NSMakeRect(100, 100, 600, 600);

model   = [inModel retain];
		window		= [[PMXWindow alloc] initWithFrame: defaultFrame styleMask:  
windowMask];


// create pastebord
		pasteBoard	= [[PMXPasteBoardView alloc] initWithFrame: [[window  
contentView] frame]];

[pasteBoard setAutoresizingMask: pasteboardMask];
[pasteBoard setVerticalMargin: 32];

		pageView	= [PMXPageView pageViewWithModel: pageModel pasteBoard:  
pasteBoard];

[pageView setColumnCount: 6];
[pageView setGutterWidth: 12];

[pasteBoard addSubview: pageView];

[window setTitle: [inModel name]];
[[window contentView] addSubview: pasteBoard];

[self show];
}

return self;
}


Here's the code that creates a page view

- (id) initWithModel:(PMXPageModel *) inModel
pasteBoard:(PMXPasteBoardView *) inPasteBoard
{
PMXDocumentModel*docModel   = [inModel 
documentModel];

NSSize  pageSize= [docModel 
size];

	NSRectselfFrame		= NSMakeRect(0, 0, pageSize.width,  
pageSize.height);


self = [super initWithFrame: selfFrame];
if (self)
{
pasteBoard  = [inPasteBoard retain];
model   = [inModel retain];
cropView= [[PMXPageCropView alloc] 
initWithPage: self];
columnView  = [[PMXPageColumnView alloc] 
initWithPage: self];

[self setAutoresizesSubviews: YES];
[self addSubview: cropView];
[self addSubview: columnView];
}

return self;
}

Here's the draw method for the page view

- (void) drawRect:(NSRect) inRect
{
NSAffineTransform   *transform  = [self transform];

[transform concat];

[[NSColor whiteColor] set];
NSRectFillUsingOperation([self frame], NSCompositeSourceOver);

[[NSColor blackColor] set];
	NSFrameRectWithWidthUsingOperation([self frame], 1,  
NSCompositeSourceOver);

}

And here's the draw method for the crop view

- (void) drawRect:(NSRect) inRect
{
PMXInsetmargins = [[[page model] documentModel] 
margins];
NSRect  selfFrame   = [self bounds],
vcrop   = NSMakeRect(left, 0, 1, 
selfFrame.size.height),
hcrop   = NSMakeRect(0, top, 
selfFrame.size.width, 1);

	// If I comment out the next line, the crop view draws at it's actual  
size

[[page transform] concat];

[[PMXColors colorForKey: @"crop rules"] set];

NSRectFillUsingOperation(hcrop, NSCompositeSourceOver);
hcrop.origin.y  = selfFrame.size.height - margins.bottom - 1;
NSRectFillUsingOperation(hcrop, NSCompositeSourceOver);

NSRectFillUsingOperation(vcrop, NSCompositeSourceOver);
vcrop.origin.x  = selfFrame.size.width - margins.right - 1;
NSRectFillUsingOperation(vcrop, NSCompositeSourceOver);

}






___

Cocoa-dev mailing list (C

Re: What's the differnece between API and Framework?

2009-05-21 Thread Todd Heberlein

ok... so an API is like a lower level framework?  wikipedia states
that Carbon and Cocoa are APIs on Mac, but i always thought those were
frameworks.


The terms are thrown around loosely. Here is how I would define them:

The API is the design or *blueprint* that tell you how to interact  
with another body of code.


The framework is the actual code that *implements* the blueprint and  
that you link with.


For example, you write your code using the Cocoa APIs (e.g., the  
function calls to the code), but when you link your program, you link  
it against *some* library/framework that implements those calls. It  
could be Apple's implementation, but in theory, you could link it  
against someone else's implementation. There was a brief period in  
time when NeXT was promoting OpenStep -- an open standard for what has  
now become Cocoa, and at least one group was writing a library to  
implement it for X windows I believe. Sun was supposed to adopt  
OpenStep as their API, but they got all wrapped up with Java and  
abandoned OpenStep... now look where they are. :)


A better example is the UNIX APIs, which allows you to write your code  
using a standard set of library/system calls, and then you can build  
your program on multiple systems using multiple implementations of the  
API.


Todd

___

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: What's the differnece between API and Framework?

2009-05-21 Thread Michael Ash
On Thu, May 21, 2009 at 9:38 PM, Chunk 1978  wrote:
> ok... so an API is like a lower level framework?  wikipedia states
> that Carbon and Cocoa are APIs on Mac, but i always thought those were
> frameworks.

They are both!

API stands for Application Programming Interface. "Interface" is the
key word. An API is not something that actually does work, it's just
an interface. In terms of a crappy metaphor, the API is the menu, and
the framework is the restaurant. The API tells you what's available
and what the stuff does, and then the framework is what actually does
the work.

For example, look at the NSString documentation. It lists a bunch of
methods, and tells you what they do. That is the NSString API. By
itself that is useless, of course. The Cocoa framework contains the
NSString *implementation* which actually makes the API do stuff.

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: What's the differnece between API and Framework?

2009-05-21 Thread Graham Cox


On 22/05/2009, at 11:38 AM, Chunk 1978 wrote:


ok... so an API is like a lower level framework?  wikipedia states
that Carbon and Cocoa are APIs on Mac, but i always thought those were
frameworks.



An API is the soup, the framework is the tin it comes in. Soup also  
comes in cartons and bowls. But if you were handed a tin of soup, you  
might just call it 'soup' rather than 'a tin of soup', since the tin  
doesn't really matter, it's just the container.


--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: Question about notifying KVO observers of changes to a property.

2009-05-21 Thread Seth Willits

On May 21, 2009, at 5:43 PM, Morales Vivó Óscar wrote:

Good point. The problem I'm having is that I don't know when to call  
the "willChange…" method, only that sometimes I need to call the  
"didChange…" one.



It's pretty straight forward.

[blah willChange...];
the_change
[blah didChange...];


You shouldn't be calling willChange and then trigger 5 million lines  
of code and hope somewhere along the lines it calls didChange. And you  
shouldn't call didChange without calling willChange.



What's the confusing part about that?


--
Seth Willits



___

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: What's the differnece between API and Framework?

2009-05-21 Thread Chunk 1978
ok... so an API is like a lower level framework?  wikipedia states
that Carbon and Cocoa are APIs on Mac, but i always thought those were
frameworks.

On Thu, May 21, 2009 at 8:50 PM, Jonathan Hess  wrote:
> An API is a set of functions, classes, methods, and other bits that give you
> a method to interface with a piece of software. A framework is one concrete
> way to package a body of software with a set of header files that describe
> its API. A web service is another way to give clients an API to a set of
> software functionality that exists on a far away server.
>
> So, you might think of a framework as one of many methods of delivering a
> package of software with an API.
>
> Jon Hess
>
> On May 21, 2009, at 5:33 PM, Chunk 1978 wrote:
>
>> my learning is still shady on what is actually an API... sounds like a
>> framework to me... ?
>> ___
>>
>> 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/jhess%40apple.com
>>
>> This email sent to jh...@apple.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: Question about notifying KVO observers of changes to a property.

2009-05-21 Thread Ken Thomases

On May 21, 2009, at 7:43 PM, Morales Vivó Óscar wrote:


On May 21, 2009, at 16:34 , Peter Duniho wrote:


On May 21, 2009, at 11:33 AM, Morales Vivó Óscar wrote:

I have an cocoa controller object with a property that is actually  
read from another, C++ object. It works fine when updating or  
reading the value, but sometimes other C++ parts of the program  
will change the value of the property and there's no good way to  
notify the cocoa controller object of the change.


I wanted to know if it's an issue from, elsewhere in the program,  
just call the object's willChangeValueForKey: and  
didChangeValueForKey: for a property that automatically notifies  
when directly changed, or if there's a more immediate and  
officially sanctioned way of letting an object know that it should  
notify its observers that one of its properties has changed its  
value.


Sorry if this is a silly question, but...

If you are able to call the associated KVO methods  
(willChangeValueForKey:, didChangeValueForKey:), why can't you just  
call the property setter?


I understand that if you've got data changing only within the C++,  
propagating that back to the Obj-C object requires extra work.  But  
if you know when to call the KVO methods, surely you're already  
propagating it somehow.  Seems like you could at that point just  
use the Obj-C object's setter instead of setting it internally to  
the C++ and calling the KVO methods directly.




Good point. The problem I'm having is that I don't know when to call  
the "willChange…" method, only that sometimes I need to call the  
"didChange…" one.


If you're asking if you can just call willChange... and then  
immediately call didChange..., both being called after the value has  
changed, then that's tricky and error prone.  You shouldn't do it.   
Calls to willChange... and didChange... should really bracket the  
actual change in value of the property.


KVO can request the value of the property during willChange... and  
during didChange...  It can cache the "old" value and use it and the  
new value during didChange...  If the cached "old" value isn't  
actually old but new, because willChange... was actually called after  
the property changed, then it can break things.  For example, KVO may  
attempt to remove observations of key subpaths from the old value  
during didChange..., but it's removing those observations from the  
wrong thing because it doesn't really have the old value.


One approach is to modify your C++ code to provide your Objective-C  
code an opportunity to call willChange... before the value actually  
changes.  It may not be appropriate for the C++ object to know about  
the Objective-C wrapper around it.  That is, you may not want tight  
coupling there.  You can use a loosely couple technique like the  
Notification design pattern.


Another approach is to make your Objective-C wrapper duplicate the  
data of the C++ object, rather than being a pass-through wrapper.  So,  
the getter for the property on your Objective-C wrapper does _not_  
call through to C++ object to get the current value.  Instead, it  
returns a cached value.  Since your C++ code apparently already  
provides a post-change notification (or can easily be made to do so),  
your Objective-C code would only change its cached copy when it  
receives that notification.  At that time, it can use a standard KVO- 
compliant setter to change its cached copy of the property value, or  
it can do willChange..., update the cache, didChange...


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: Question about notifying KVO observers of changes to a property.

2009-05-21 Thread Peter Duniho

On May 21, 2009, at 5:43 PM, Morales Vivó Óscar wrote:


On May 21, 2009, at 16:34 , Peter Duniho wrote:


On May 21, 2009, at 11:33 AM, Morales Vivó Óscar wrote:

I have an cocoa controller object with a property that is  
actually read from another, C++ object. It works fine when  
updating or reading the value, but sometimes other C++ parts of  
the program will change the value of the property and there's no  
good way to notify the cocoa controller object of the change.


I wanted to know if it's an issue from, elsewhere in the program,  
just call the object's willChangeValueForKey: and  
didChangeValueForKey: for a property that automatically notifies  
when directly changed, or if there's a more immediate and  
officially sanctioned way of letting an object know that it  
should notify its observers that one of its properties has  
changed its value.


Sorry if this is a silly question, but...

If you are able to call the associated KVO methods  
(willChangeValueForKey:, didChangeValueForKey:), why can't you  
just call the property setter? [...]




Good point. The problem I'm having is that I don't know when to call  
the "willChange…" method, only that sometimes I need to call the  
"didChange…" one.


Um, okay.  So did I misunderstand the question?  You seemed to be  
asking whether there would be a problem calling "willChange…" and  
"didChange…" when you change the value directly in C++.


I don't have an answer for what the best way to solve the problem  
would be.  But if it were me, I'd do one of two things, depending on  
how much encapsulation you want in your C++ code (i.e. do you want the  
C++ code to know about your Obj-C class, or Obj-C at all?).


If you want encapsulation, I'd implement some kind of "event" pattern  
in your C++ code, by which a client callback can be executed whenever  
the value needs to be updated.  Then your Obj-C class can use a C/C++  
helper function or class to subscribe to the event, which would then  
forward that to the Obj-C object itself, where the appropriate KVO  
notifications can be handled.


If you don't want that much encapsulation, then I would just make all  
value changes go through the Obj-C object, which the C++ code would  
know about.  In the C++ code, rather than setting the value privately,  
you'd always set it through the Obj-C setter, which would of course  
turn around and set the C++ value (and implicitly raise the  
appropriate KVO notifications).


Basically, it seems to me that the first step you need to address is  
how to inform the Obj-C object of changes from within the C++ code.   
Until you've solved that aspect, I think it's premature to wonder what  
the precise mechanism for raising a KVO notification is, should be, or  
can be.


As for the question as to whether it's kosher to execute the  
"willChange…" and "didChange…" methods explicitly (assuming that's a  
question you're asking...as you can see, I'm not entirely sure about  
that :) ), since the docs say "You invoke this method when  
implementing key-value observer compliance manually", I'd say that's  
exactly what Apple expects you to do.  :)


If you don't use the second approach I describe (always going through  
the Obj-C setter, even from your C++ code), one thing you should  
probably be careful of is the question of updating the value before  
the "willChange…" method has been executed.  In other words, you  
probably don't want to just have the C++ code sending a single  
notification to the Obj-C object; if the value change is going to be  
handled privately within the C++ code, the C++ code needs to provide a  
notification both before and after the value has changed.


Obviously if you always go through the Obj-C setter, even to set the  
value from within the C++ code, then the KVO notifications will be  
handled automatically and in the correct order.  :)


Pete___

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: What's the differnece between API and Framework?

2009-05-21 Thread Jonathan Hess
An API is a set of functions, classes, methods, and other bits that  
give you a method to interface with a piece of software. A framework  
is one concrete way to package a body of software with a set of header  
files that describe its API. A web service is another way to give  
clients an API to a set of software functionality that exists on a far  
away server.


So, you might think of a framework as one of many methods of  
delivering a package of software with an API.


Jon Hess

On May 21, 2009, at 5:33 PM, Chunk 1978 wrote:


my learning is still shady on what is actually an API... sounds like a
framework to me... ?
___

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/jhess%40apple.com

This email sent to jh...@apple.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: Question about notifying KVO observers of changes to a property.

2009-05-21 Thread Morales Vivó Óscar
Good point. The problem I'm having is that I don't know when to call  
the "willChange…" method, only that sometimes I need to call the  
"didChange…" one.


On May 21, 2009, at 16:34 , Peter Duniho wrote:


On May 21, 2009, at 11:33 AM, Morales Vivó Óscar wrote:

I have an cocoa controller object with a property that is actually  
read from another, C++ object. It works fine when updating or  
reading the value, but sometimes other C++ parts of the program  
will change the value of the property and there's no good way to  
notify the cocoa controller object of the change.


I wanted to know if it's an issue from, elsewhere in the program,  
just call the object's willChangeValueForKey: and  
didChangeValueForKey: for a property that automatically notifies  
when directly changed, or if there's a more immediate and  
officially sanctioned way of letting an object know that it should  
notify its observers that one of its properties has changed its  
value.


Sorry if this is a silly question, but...

If you are able to call the associated KVO methods  
(willChangeValueForKey:, didChangeValueForKey:), why can't you just  
call the property setter?


I understand that if you've got data changing only within the C++,  
propagating that back to the Obj-C object requires extra work.  But  
if you know when to call the KVO methods, surely you're already  
propagating it somehow.  Seems like you could at that point just use  
the Obj-C object's setter instead of setting it internally to the C+ 
+ and calling the KVO methods directly.


Pete___

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/oscarmv%40mac.com

This email sent to osca...@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


What's the differnece between API and Framework?

2009-05-21 Thread Chunk 1978
my learning is still shady on what is actually an API... sounds like a
framework to me... ?
___

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: Privilege elevation of a cocoa app

2009-05-21 Thread Erg Consultant
Never run an 'app' as privileged. You need a helper tool to do that. You have a 
lot of reading ahead of you to understand how to do this.

Erg





From: Jerry Krinock 
To: "cocoa-dev@lists.apple.com Developers" 
Sent: Thursday, May 21, 2009 4:25:15 AM
Subject: Re: Privilege elevation of a cocoa app


On 2009 May 21, at 02:49, Arun wrote:

> I have an application which when launched asks for user to authenticate for
> admin rights.

Eyebrows are raised.

> After user authenticates the app is launched. I thought after authentication
> the Application executes with admin privilages. But is is still executing in
> user privilages only.
> Is there any way in which i can elevate the privilege of the  binary after
> authentication.

You need to re-post this question to a different list where it will be on-topic:

http://lists.apple.com/mailman/listinfo/apple-cdsa

Also, from what I've read so far, prepare to be told that you're doing things 
wrong and that your application is a threat to national security.

___

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/erg_consultant%40yahoo.com

This email sent to erg_consult...@yahoo.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


garbage collection and pointer to object

2009-05-21 Thread Michael Link

I have a class with the following methods

- (void)save
{
NSError* error = nil;

if (![self save:&error]) {
NSLog(@"caught error during save: %@", error);
}
}

- (BOOL)save:(NSError**)error
{
if (![_thread isCancelled]) {
return [_managedObjectContext save:error];
}

return YES;
}

When -save is called it calls -save: to get error information if an  
error occurs while saving an NSManagedObjectContext. When an error  
does occur sometimes a crash will occur at NSLog when trying to get  
the NSError description. Is it possible that the local variable error  
in -save is being garbage collected before NSLog is called?


Thread 0 Crashed:
0   com.apple.CoreFoundation  	0x7fff833bd24a  
CFBundleCopyLocalizedString + 90
1   com.apple.CoreFoundation  	0x7fff833db111  
_CFErrorCreateLocalizedDescription + 273
2   com.apple.Foundation  	0x7fff81f0f3f8 -[NSError  
localizedDescription] + 136
3   com.apple.CoreFoundation  	0x7fff833db25a  
CFErrorCopyDescription + 138
4   com.apple.CoreFoundation  	0x7fff833db2b4  
_CFErrorCreateDebugDescription + 36
5   com.apple.Foundation  	0x7fff81f0f349 -[NSError  
description] + 9
6   com.apple.Foundation  	0x7fff81e83770  
_NSDescriptionWithLocaleFunc + 128
7   com.apple.CoreFoundation  	0x7fff83428b54  
_CFStringAppendFormatAndArgumentsAux + 2964
8   com.apple.CoreFoundation  	0x7fff83429fa8  
_CFStringCreateWithFormatAndArgumentsAux + 120

9   com.apple.CoreFoundation0x7fff8345dab0 _CFLogvEx + 64
10  com.apple.Foundation0x7fff81e9ba0b NSLogv + 139
11  com.apple.Foundation0x7fff81ef69a2 NSLog + 162
12  net.fractal.Bug	0x000100094d74 0x1 +  
609652
13  net.fractal.Bug	0x000100050e58 0x1 +  
331352
14  com.apple.CoreFoundation  	0x7fff8347dead __invoking___ +  
141
15  com.apple.CoreFoundation  	0x7fff8347d774 -[NSInvocation  
invoke] + 148
16  net.fractal.Bug	0x000100040b6d 0x1 +  
265069
17  com.apple.CoreFoundation  	0x7fff8347dead __invoking___ +  
141
18  com.apple.CoreFoundation  	0x7fff8347d774 -[NSInvocation  
invoke] + 148
19  com.apple.CoreFoundation  	0x7fff8347d833 -[NSInvocation  
invokeWithTarget:] + 51
20  com.apple.Foundation  	0x7fff81e7f754  
__NSThreadPerformPerform + 148
21  com.apple.CoreFoundation  	0x7fff83404008  
CFRunLoopRunSpecific + 2808
22  com.apple.HIToolbox   	0x7fff82a71bce  
RunCurrentEventLoopInMode + 278
23  com.apple.HIToolbox   	0x7fff82a71963  
ReceiveNextEventCommon + 161
24  com.apple.HIToolbox   	0x7fff82a718af  
BlockUntilNextEventMatchingListInMode + 79
25  com.apple.AppKit  	0x7fff80a89420 _DPSNextEvent +  
603
26  com.apple.AppKit  	0x7fff80a88d61 -[NSApplication  
nextEventMatchingMask:untilDate:inMode:dequeue:] + 136
27  com.apple.AppKit  	0x7fff80d07457 -[NSScrollView  
scrollWheel:] + 721
28  com.apple.AppKit  	0x7fff80be9d59 forwardMethod +  
100
29  com.apple.AppKit  	0x7fff80d0716e -[NSView  
scrollWheel:] + 249
30  com.apple.AppKit  	0x7fff80be9d59 forwardMethod +  
100
31  com.apple.AppKit  	0x7fff80d0716e -[NSView  
scrollWheel:] + 249
32  com.apple.AppKit  	0x7fff80b5b40b -[NSWindow  
sendEvent:] + 6820
33  com.apple.AppKit  	0x7fff80b282f6 -[NSApplication  
sendEvent:] + 5089
34  com.apple.AppKit  	0x7fff80a82b20 -[NSApplication  
run] + 499
35  com.apple.AppKit  	0x7fff80a4f8ac  
NSApplicationMain + 373
36  net.fractal.Bug	0x000196fb 0x1 +  
38651
37  net.fractal.Bug	0x000121b8 0x1 +  
8632


Thread 1:
0   libauto.dylib  	0x0001006876e4  
Auto::Admin::deallocate(void*) + 772
1   libauto.dylib  	0x00010068e623  
Auto::Zone::block_deallocate_internal(void*) + 355
2   libauto.dylib  	0x00010067c1cd  
auto_collect_internal(Auto::Zone*, unsigned int) + 2685
3   libauto.dylib  	0x00010067c380  
auto_collection_thread(void*) + 112
4   libSystem.B.dylib 	0x7fff827ade8b _pthread_start +  
316

5   libSystem.B.dylib   0x7fff827add4d thread_start + 13


--
Michael
___

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: Question about notifying KVO observers of changes to a property.

2009-05-21 Thread Peter Duniho

On May 21, 2009, at 11:33 AM, Morales Vivó Óscar wrote:

I have an cocoa controller object with a property that is actually  
read from another, C++ object. It works fine when updating or  
reading the value, but sometimes other C++ parts of the program will  
change the value of the property and there's no good way to notify  
the cocoa controller object of the change.


I wanted to know if it's an issue from, elsewhere in the program,  
just call the object's willChangeValueForKey: and  
didChangeValueForKey: for a property that automatically notifies  
when directly changed, or if there's a more immediate and officially  
sanctioned way of letting an object know that it should notify its  
observers that one of its properties has changed its value.


Sorry if this is a silly question, but...

If you are able to call the associated KVO methods  
(willChangeValueForKey:, didChangeValueForKey:), why can't you just  
call the property setter?


I understand that if you've got data changing only within the C++,  
propagating that back to the Obj-C object requires extra work.  But if  
you know when to call the KVO methods, surely you're already  
propagating it somehow.  Seems like you could at that point just use  
the Obj-C object's setter instead of setting it internally to the C++  
and calling the KVO methods directly.


Pete___

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: link to a Framework from within a sub bundle [solved]

2009-05-21 Thread Richard Salvatierra
The framework needs the "Installation Directory" as  
@executable_path/../Frameworks


I have an application with a copy phase that places a custom  
framework in the the app bundle /Contents/Frameworks/ folder. I also  
have bundles in /Contents/Modules/ folder of the main bundle. My  
question is: How do I link to a Framework in the main bundle / 
Contents/Frameworks/ folder from a Bundle located in the /Contents/ 
Modules/?


___

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: Controlling some of CoreAnimation's more confusing automation

2009-05-21 Thread Gwynne Raskind

On May 21, 2009, at 1:09 PM, David Duncan wrote:
I have a UIView that contains a number of CALayers. Nothing unusual  
here. The CALayers are subclassed to do their drawing, because that  
was easier than separating the delegate logic from my UIView  
subclass (since the view can't be the delegate of a sublayer - it  
causes an infinite recursion to do so, why isn't there a check for  
this somewhere in CA's or Cocoa Touch's code?).
UIKit expects that a view and layer are tightly coupled and that the  
view is not a shared delegate between multiple layers, period. Even  
if it worked, you would see a lot of behavior that you may not  
desire by setting a view as a layer's delegate.


My question, though, is why isn't there an assert somewhere in the CA  
or UIView logic that says "WARNING, WARNING, YOU'VE DONE SOMETHING  
BAD!!!" Throw an exception or something! :)


1) animate the custom properties more directly with a  
CABasicAnimation. I tried this, but it did nothing at all.
Custom property animation is not supported on iPhone OS 2.x or Mac  
OS X 10.5.


Well, here's hoping for that support in a future release.

2) get some control over the implicit animation CA is setting up  
for the contents transition. CATransaction only lets me set  
duration and the "is enabled" flag, whereas CAMediaTiming has a  
whole pile of useful parameters.
You can change the default animation for any property of a layer.  
See the documentation for -actionForKey: for more information.


Ah ha! This is what I was looking for, thanks!

-- Gwynne, Daughter of the Code
"This whole world is an asylum for the incurable."



___

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


Question about notifying KVO observers of changes to a property.

2009-05-21 Thread Morales Vivó Óscar
I have an cocoa controller object with a property that is actually  
read from another, C++ object. It works fine when updating or reading  
the value, but sometimes other C++ parts of the program will change  
the value of the property and there's no good way to notify the cocoa  
controller object of the change.


I wanted to know if it's an issue from, elsewhere in the program, just  
call the object's willChangeValueForKey: and didChangeValueForKey: for  
a property that automatically notifies when directly changed, or if  
there's a more immediate and officially sanctioned way of letting an  
object know that it should notify its observers that one of its  
properties has changed its value.


Thanks in advance for your help:

Óscar Morales Vivó.___

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


link to a Framework from within a sub bundle

2009-05-21 Thread Richard Salvatierra
I have an application with a copy phase that places a custom framework  
in the the app bundle /Contents/Frameworks/ folder. I also have  
bundles in /Contents/Modules/ folder of the main bundle. My question  
is: How do I link to a Framework in the main bundle /Contents/ 
Frameworks/ folder from a Bundle located in the /Contents/Modules/?


-Rich
___

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: Questions re: Core Audio, offline rendering

2009-05-21 Thread Kyle Sluder
On Thu, May 21, 2009 at 1:18 PM, dct  wrote:
> Is this the correct forum?

No, you want coreaudio-api.

--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: isKindOfClass returns null instead of YES or NO

2009-05-21 Thread Bill Bumgarner

On May 21, 2009, at 9:53 AM, Gwynne Raskind wrote:
You will find that Apple has indeed dropped in -Wformat checks for  
"nsstring_format_type" and "cfstring_format_type". But if you scroll  
down a ways further, you'll find that OOPS!, Apple hasn't actually  
implemented those types, at least not completely. One wonders why.  
Bug filing time, anyone?


No need.  It is a very well known bug and has been on the todo list  
for a long time.   For reasons beyond the scope of cocoa-dev, it is  
actually pretty darned hard to make it work correctly enough to ship a  
solution.


It'll be fixed in a future release.  Hopefully near future instead of  
distant future, but... who knows?


b.bum

___

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

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

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

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


Re: Best way to draw text in CAOpenGLLayer

2009-05-21 Thread David Duncan

On May 21, 2009, at 10:12 AM, David Duncan wrote:

Don't. Use a CATextLayer (which can render text for you) or a  
CALayer (to display image content) instead. Unless you want to get  
outlines of your text, the CAOpenGLLayer is really not a good way to  
do this.



Clarifying a bit - unless you want to render your text as vector  
graphics, then you don't want to use an OpenGL layer to do this.

--
David Duncan
Apple DTS Animation and Printing

___

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


Questions re: Core Audio, offline rendering

2009-05-21 Thread dct

Is this the correct forum?

If yes I have several questions:

I need to convert formatted audio(mp3, etc) files to continuous,  
linear pcm data in a memory buffer--i.e., a basic process of reading  
from disc, converting, and transferring to buffer.


Using Core Audio, I infer that I can to do the following:

1. Read formatted audio data into an input buffer--NSHandle methods do  
this just fine.


2. Create a file stream parser-- i.e.,
AudioFileStreamOpen( self, propertyCallback, packetCallback,  
hint, &fileParserID )


3. Parse the buffered input--
AudioFileStreamParseBytes( fileParserID, inBufSize, inBuffer,  
0 );


4. (in propertyCallback function) -- when inPropertyID is  
"..._ReadyToProducePackets":

a.  Get AudioStreamBasicDescription--
AudioFileStreamGetProperty( inAudioFileStream,
kAudioFileStreamProperty_DataFormat, &asbdSize, 
&asbd );
 -All seems ok to here.-
b.  Establish an audio queue--.
AudioQueueNewOutput( &asbd, queueCallback, inBuffer,

NULL, NULL, 0, &queue);
?? What does the callback process need to do, or is it  
needed,

  given offline rendering??
c.  Allocate an audio queue buffer
AudioQueueAllocateBuffer( queue, nbytes, &queueBuffer );
d.  Set queue to render offline
AudioQueueSetOfflineRenderFormat( queue, &asbd,  
&chLayout );
?? What setting for channel layout & why is it needed for  
offline??


5. (in packetCallback)  -- at each step of looping through the parsed  
packets:

a.  Copy packet data to queue buffer
memcpy( queueBuffer->mAudioData +bytesFilled, inInputData 
+pcktOffset, pcktSize)

b.  Update bytesFilled and pcktOffset
-- then after loop completion (or perhaps within the loop):
c.Render the packet data to pcm
	AudioQueueOfflineRender( queue, timeStamp, outputBuffer,  
mFramesPerPacket)
?? Why timestamp for offline?  And can timeStamp be set  
as NULL??
	 ?? I assume that the output pcm is SInt16 for each channel of each  
frame.
   If so, this means that for an mp3 case, 1152  
frames/pckt & 2 chan/ftm, the
   pcm output for every packet should be 4608 bytes.   
However, for that case,
   the variable queueBuffer->mAudioDataBytesCapacity  
= 4640.  Why the
   extra 32 bytes (or am I misunderstanding  
DataBytesCapacity variable)??

?? At this point, with a 0 time stamp I get an error code = -66626.
  I cannot find any reference to this error--what doe it mean??

I'll appreciate any and all help and advice.  Thanks, Don Thompson
___

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: Privilege elevation of a cocoa app

2009-05-21 Thread Greg Guerin

Todd Heberlein wrote:

For example, I use HelperTool to open a specific file that require  
root access, and then I pass the file descriptor back to my Cocoa  
application.



man authopen

/usr/libexec/authopen -h

  -- GG

___

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 draw text in CAOpenGLLayer

2009-05-21 Thread David Duncan

On May 21, 2009, at 3:23 AM, Anshul jain wrote:


I am trying to scroll text in CAOpenGLLayer



Don't. Use a CATextLayer (which can render text for you) or a CALayer  
(to display image content) instead. Unless you want to get outlines of  
your text, the CAOpenGLLayer is really not a good way to do this.

--
David Duncan
Apple DTS Animation and Printing

___

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: Escaping white space in an NSString

2009-05-21 Thread Greg Guerin

Bruce Johnson wrote:


char  mdfile[PATHSIZE];
strncpy(mdfile, , MAXREAD);

FILE * stream = fopen(, "rt");


On further reflection, this code fragment looks very suspicious.

First, a local char buffer of length PATHSIZE is declared.  We don't  
know what PATHSIZE is.


Second, some unknown variable is copied into that buffer, but the  
length is declared as MAXREAD, when it really ought to be PATHSIZE.


Since we don't know MAXREAD's magnitude relative to PATHSIZE, nor do  
we know what  really is, this could cause a buffer  
overflow.  Equally bad, if MAXREAD is less than the strlen of  
, strncpy() will not put a NUL terminator on the copied  
data, and subsequent calls that expect a nul-terminated C string  
(viz. fopen()) will not do the right thing.


A typical idiom for using strncpy() with buffers whose length is  
known is:

  strncpy( dstBuf, srcBuf, sizeof(dstBuf) );

Note this idiom only works when dstBuf is declared as an array of  
definite length.  It won't work when dstBuf is a pointer expression.


Third, the 'mdfile' buffer that just received a copy of   
is now ignored, and the original  is used as the filename  
to fopen().  So what was the purpose of mdfile and the strncpy()  
anyway?  If mdfile is used later, why copy  into it?  If  
mdfile isn't used later, why have it at all?


Fourth, the second arg to fopen is "rt".  However, the man page for  
fopen shows no significant for the 't' character.  Optional 'b' or  
'x', yes, but no 't'.


There is a '+' character recognized by fopen(), and '+' looks  
somewhat like 't', but that's the only explanation I can imagine for  
what "rt" might have been intended to mean.  If that was the intent,  
it's wrong.  If that wasn't the intent, then an explanation for 't'  
might be useful.


http://developer.apple.com/documentation/Darwin/Reference/Manpages/ 
man3/fopen.3.html


  -- GG

___

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: Controlling some of CoreAnimation's more confusing automation

2009-05-21 Thread David Duncan

On May 20, 2009, at 7:04 PM, Gwynne Raskind wrote:

I have a UIView that contains a number of CALayers. Nothing unusual  
here. The CALayers are subclassed to do their drawing, because that  
was easier than separating the delegate logic from my UIView  
subclass (since the view can't be the delegate of a sublayer - it  
causes an infinite recursion to do so, why isn't there a check for  
this somewhere in CA's or Cocoa Touch's code?).


UIKit expects that a view and layer are tightly coupled and that the  
view is not a shared delegate between multiple layers, period. Even if  
it worked, you would see a lot of behavior that you may not desire by  
setting a view as a layer's delegate.


1) animate the custom properties more directly with a  
CABasicAnimation. I tried this, but it did nothing at all.


Custom property animation is not supported on iPhone OS 2.x or Mac OS  
X 10.5.


2) get some control over the implicit animation CA is setting up for  
the contents transition. CATransaction only lets me set duration and  
the "is enabled" flag, whereas CAMediaTiming has a whole pile of  
useful parameters.



You can change the default animation for any property of a layer. See  
the documentation for -actionForKey: for more information.

--
David Duncan
Apple DTS Animation and Printing

___

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: isKindOfClass returns null instead of YES or NO

2009-05-21 Thread Sean McBride
On 5/21/09 12:44 PM, Kyle Sluder said:

>> And if you're wondering if the compiler could warn you that %@ and BOOL
>> do not match, the answer is unfortunately no.  -Wformat=2 can give such
>> warnings when using sprintf() and friends, but not NSString methods.
>> One of my pet peeves. :)
>
>Not so according to Matt Gallagher:
>http://cocoawithlove.com/2009/05/variable-argument-lists-in-cocoa.html

You have but to try for yourself:

--
#import 

int main (int argc, char * const argv[])
{
BOOL flag = NO;
NSLog (@"%@", flag);
}
--

$ gcc-4.2 -Wformat=2 /Users/sean/Desktop/test.m

It could be that the compiler is capable but Apple's headers are lacking
proper declarations.  But it makes little difference to us users exactly why.

--

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: Tools in App Bundles

2009-05-21 Thread Jerry Krinock


On 2009 May 20, at 23:20, Kevin LaCoste wrote:

The docs clearly state that anything in Contents/MacOS is covered by  
the app bundles signature.


Nope.  The Code Signing Guide is ambiguous at best on this point, and  
so I just sent them feedback "It wasn't helpful".


Also, it does not work according to your interpretation:

# Sign the bundle:
Jerrys-Mac-Mini:~ jk$ codesign -s "Sheep Systems Code Signing" -i  
BookMacster -v "/Users/jk/Documents/Programming/Builds/Debug/ 
BookMacster.app"
/Users/jk/Documents/Programming/Builds/Debug/BookMacster.app: signed  
bundle with Mach-O thin (i386) [BookMacster]


# Check if helper in Contents/MacOS got signed:
Jerrys-Mac-Mini:~ jk$ codesign -dv "/Users/jk/Documents/Programming/ 
Builds/Debug/BookMacster.app/Contents/MacOS/ 
AuthorizedTaskHelperToolInstaller"/Users/jk/Documents/Programming/ 
Builds/Debug/BookMacster.app/Contents/MacOS/ 
AuthorizedTaskHelperToolInstaller: code object is not signed


# Sign that helper itself:
Jerrys-Mac-Mini:~ jk$ codesign -s "Sheep Systems Code Signing" -i  
BookMacster -v "/Users/jk/Documents/Programming/Builds/Debug/ 
BookMacster.app/Contents/MacOS/AuthorizedTaskHelperToolInstaller"
/Users/jk/Documents/Programming/Builds/Debug/BookMacster.app/Contents/ 
MacOS/AuthorizedTaskHelperToolInstaller: signed Mach-O thin (i386)  
[BookMacster]


# Check it again:
Jerrys-Mac-Mini:~ jk$ codesign -dv "/Users/jk/Documents/Programming/ 
Builds/Debug/BookMacster.app/Contents/MacOS/ 
AuthorizedTaskHelperToolInstaller"Executable=/Users/jk/Documents/ 
Programming/Builds/Debug/BookMacster.app/Contents/MacOS/ 
AuthorizedTaskHelperToolInstaller

Identifier=BookMacster
Format=Mach-O thin (i386)
CodeDirectory v=20001 size=196 flags=0x0(none) hashes=5+2  
location=embedded

Signature size=1680
Signed Time=2009 May 21 09:43:13
Info.plist=not bound
Sealed Resources=none
Internal requirements count=0 size=12

#

Read the new message from Perry in that thread I linked to yesterday.   
He's clarified this further.


And again, we should be discussing this over there instead of here,  
although I believe it's settled now :)


___

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: Privilege elevation of a cocoa app

2009-05-21 Thread Todd Heberlein


Is there any way in which i can elevate the privilege of the  binary  
after

authentication.


Look at the BetterAuthorizationSample code and documentation at
http://developer.apple.com/referencelibrary/Security/idxAuthorization-date.html

Basically you put your privileged code in a non-GUI application (e.g.,  
a BSD shell application) called "HelperTool" in the  
BetterAuthorizationSample (BAS). One of the reasons for this is you  
don't want to incorporate a huge amount of GUI and other library code  
that might have bugs (my apologizes to Apple engineers) into a  
privileged process. Also, you usually have only a very small amount of  
code in the HelperTool that needs to run with privileges, so it is  
easier to check for your own bugs. The HelperTool is then started by  
launchd, which can launch it with an elevated privileges. The BAS  
library code provides some APIs to pass arguments to, and receive data  
back from the HelperTool.


For example, I use HelperTool to open a specific file that require  
root access, and then I pass the file descriptor back to my Cocoa  
application.


Still, it took me a little while to figure out how to integrate the  
BAS code into my own -- there are quite a few steps you need to follow.


Todd

___

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: isKindOfClass returns null instead of YES or NO

2009-05-21 Thread Gwynne Raskind

On May 21, 2009, at 12:33 PM, Sean McBride wrote:

NSLog(@"Is Member of NSURL: %@", [[step class] isMemberOfClass:
[NSURL class]]);

The %@ placeholder is for arguments that are objects.
isMemberOfClass: and isKindOfClass: return a BOOL, which is not an
object.

Jeff,

And if you're wondering if the compiler could warn you that %@ and  
BOOL
do not match, the answer is unfortunately no.  -Wformat=2 can give  
such

warnings when using sprintf() and friends, but not NSString methods.
One of my pet peeves. :)



Interestingly enough, if you pop over to:

http://www.opensource.apple.com/source/gcc_42/gcc_42-5531/gcc/c-format.c

You will find that Apple has indeed dropped in -Wformat checks for  
"nsstring_format_type" and "cfstring_format_type". But if you scroll  
down a ways further, you'll find that OOPS!, Apple hasn't actually  
implemented those types, at least not completely. One wonders why. Bug  
filing time, anyone?


-- Gwynne, Daughter of the Code
"This whole world is an asylum for the incurable."



___

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: problems with inspector window

2009-05-21 Thread Kyle Sluder
Override -shouldCloseDocument in your NSWindowController subclass to return NO.

I'm not sure about the way this inspector has been implemented... it
seems to be confusing the NSDocument machinery a bit.

--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: isKindOfClass returns null instead of YES or NO

2009-05-21 Thread Kyle Sluder
On Thu, May 21, 2009 at 12:33 PM, Sean McBride  wrote:
> And if you're wondering if the compiler could warn you that %@ and BOOL
> do not match, the answer is unfortunately no.  -Wformat=2 can give such
> warnings when using sprintf() and friends, but not NSString methods.
> One of my pet peeves. :)

Not so according to Matt Gallagher:
http://cocoawithlove.com/2009/05/variable-argument-lists-in-cocoa.html

--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: Binding 'Enabled' to NSObjectController.selection NSIsNotNil fails?

2009-05-21 Thread Sean McBride
On 5/20/09 10:35 PM, Seth Willits said:

>I have an NSObjectController whose Content item is bounds to an
>object's "thing" path. I can then bind the values of controls in my
>nib to model key paths through that NSObjectController in the usual
>way. Those Value bindings can use "Conditionally Sets Enabled" and
>they work great.
>
>I have some controls where I'm not binding the Value though, and
>instead just need to bind Enabled alone, so that when there is no
>selection in the controller, those controls are disabled.
>
>The obvious way of doing that is to bind 'Enabled' to the
>NSObjectController's "selection" controller key, (no model key), and
>use the value transformer NSIsNotNil. Anytime the selection is not
>nil, the control is enabled... right? It's super simple, but it doesn't
>work, and I don't see why not.

My solution to all this was to create an NSValueTransformer subclass
that converts an NSArray/NSSet (anything that responds to count
actually) and converts to an NSNumber representing the number of items
in the collection.  Then I register 4 transformers named
RRCountIsZeroTransformer, RRCountIsNotZeroTransformer,
RRCountIsOneTransformer, and RRCountIsNotOneTransformer and use these in
my 'enabled' bindings.

--

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


Resizing Funky

2009-05-21 Thread Walker Argendeli
I have a window with a tableview inside it, along with many other  
views.  When I click the resize button, most things do what they're  
supposed to, except for two things: the table and title bar.  The  
title bar goes completely white, except for the "hide toolbar" button  
which moves into a spot inside the table view (perhaps all the buttons  
in the title bar have moved there and are simply out of view).  The  
table itself isn't expanding all the way to the left, and the vertical  
scrollbar moves a third to the left and just floats over the table,  
leaving a white bar where it should be.  It also remains at its  
original size.  If I click on the "remove toolbar" dimple twice, I get  
my title bar back and the scroll bar goes to the correct size and  
moves over, leaving a black line where it used to be.  The table also  
remains not entirely expanded.
In Xcode, I get this in the console: Column identifiers used with  
NSTableView autosave feature must conform to NSCoding protocol.
I don't use column identifiers that I was aware of (or autosave)  I'm  
not even sure how to use that...
Lastly, it's very difficult to resize by dragging the corner: moves a  
pixel or two and stops.


If anyone could give me ideas on what to look for to solve this, I'd  
appreciate it.

- Walker Argendeli

___

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: isKindOfClass returns null instead of YES or NO

2009-05-21 Thread Sean McBride
On 5/20/09 11:45 PM, Andy Lee said:

>>  NSLog(@"Is Member of NSURL: %@", [[step class] isMemberOfClass:
>> [NSURL class]]);
>
>The %@ placeholder is for arguments that are objects.
>isMemberOfClass: and isKindOfClass: return a BOOL, which is not an
>object.

Jeff,

And if you're wondering if the compiler could warn you that %@ and BOOL
do not match, the answer is unfortunately no.  -Wformat=2 can give such
warnings when using sprintf() and friends, but not NSString methods.
One of my pet peeves. :)

--

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: Feed Parsing Framework ...

2009-05-21 Thread Dave DeLong

http://www.cocoabuilder.com/archive/message/cocoa/2009/4/12/234437

Cheers,

Dave

On May 21, 2009, at 9:29 AM, Mic Pringle wrote:


A week or two ago, a subscriber to this list announced a new framework
for parsing rss feeds.

I seem to have misplaced the email, and can't find the announcement on
CocoaBuilder.

Can anyone remember the link (I think it pointed to a Github repo) or
could the author perhaps come forward ?

Thanks

-Mic
___

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/davedelong%40me.com

This email sent to davedel...@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: Best way to draw text in CAOpenGLLayer

2009-05-21 Thread Corbin Dunn


But the scrolling is not smooth and the CPU usage was 60 % -  80%. I  
think application is taking time to convert NSString into a CGImage.


Do you know that is the case? If you have any performance issue, you  
should use sample and Shark. Then you can try to figure out what is  
wrong.


-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: Apple Sample Code not working? SampleCMPlugin

2009-05-21 Thread Eric Schlegel


On May 21, 2009, at 1:23 AM, Steve Cronin wrote:

No matter what text I select this ALWAYS fails.  The plugin NEVER  
detects text correctly.
I have set up a generic coerce method and tested for both of these  
as well as:
typeUnicodeText, typeStyledText, typeIntlText, typeCFStringRef   
(They all fail!)


I'm assuming that you're testing this after selecting text within a  
Cocoa app, such as TextEdit. Unfortunately, Cocoa never provides the  
selected text when it displays the contextual menu, so there's no way  
to access it.


-eric

___

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: Escaping white space in an NSString

2009-05-21 Thread Greg Guerin

Bruce Johnson wrote:

The CLI is for a Cocoa App, but I need to call this in both Leopard  
and iPhone



Please explain exactly what you mean by the acronym CLI.  None of the  
interpretations I'm familiar with fit what you're doing.  Or if they  
do, you're not explaining how you have a Command Line Interpreter/ 
Interface on iPhone.


  http://en.wikipedia.org/wiki/CLI



char  mdfile[PATHSIZE];
strncpy(mdfile, , MAXREAD);

FILE * stream = fopen(, "rt");



Please post your real code.  Do not substitute placeholders like  
.


When you eliminate things you think aren't relevant, it prevents  
anyone from seeing the entire context.  And since you're having a  
problem, what you think is relevant may be contributing to the  
problem, so eliminating it could remove the very thing we need to see.


  -- GG

___

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

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

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

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


Fwd: Memory management in QuickLook plugin

2009-05-21 Thread Georg Seifert

As alway I didn’t send it to the list...



Use Zombies and Instruments.



http://www.corbinstreehouse.com/blog/index.php/2007/10/instruments-on-leopard-how-to-debug-those-random-crashes-in-your-cocoa-app/



I do this all the time, but can’t figure out how to use Instruments  
with "quicklookd". I can run it but how do I supply the argument.  
If I use "qlmanage" everything works fine.




Unfortunately, I don't know -- sorry!

I would suspect that if it is a consistent memory issue, running  
with NSZombiesEnabled and glmanage should make it happen consistently.


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: Menu item with 'title' bound is always enabled. Bug?

2009-05-21 Thread Sean McBride
On 5/20/09 6:21 PM, Jerry Krinock said:

>On a main menu item, I've set a delegate which implements -
>menuNeedsUpdate:.  In this method, I enable/disable some items and
>also modify some item titles based on current conditions.
>
>With some items, however, instead of sending -setTitle: in -
>menuNeedsUpdate:, I had bound their 'title' in Interface Builder.  But
>I just discovered that this 'title' binding was causing setEnabled:NO
>sent to these items during -menuNeedsUpdate: to be ignored.  A menu
>item with a 'title' bound is always enabled.

I've noticed something similar.  I have a few menu items where I bind
their 'enabled' binding.  This seems to make them always enabled/
disabled based on that binding (which I guess makes sense).  However, it
means you loose the nice feature where they are auto-disabled based on
the responder chain.  So, for example, if a modal NSAlert is being
displayed, those menu items are still enabled.

--

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: Privilege elevation of a cocoa app

2009-05-21 Thread Michael Ash
On Thu, May 21, 2009 at 5:49 AM, Arun  wrote:
> Hi All,
>
> I have an application which when launched asks for user to authenticate for
> admin rights.
> After user authenticates the app is launched. I thought after authentication
> the Application executes with admin privilages. But is is still executing in
> user privilages only.
> Is there any way in which i can elevate the privilege of the  binary after
> authentication.

No. It is a fundamental design feature of UNIX that a process's
privileges can only decrease, never increase.

What Authorization Services allows you to do is run a *new* process
with elevated privileges.

This stuff is extremely complex and you can't just blunder around in
it hoping to find the right magic combination. Read through Apple's
sample code extensively, and borrow from it as much as you possibly
can:

http://developer.apple.com/samplecode/Security/idxAuthorization-date.html

Yes, that sample code is all extremely difficult and complex, but
that's because you've picked a task which is extremely difficult and
complex.

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: isKindOfClass returns null instead of YES or NO

2009-05-21 Thread Michael Ash
On Wed, May 20, 2009 at 11:43 AM, Jeff Decker  wrote:
> Hello,
> I am working through the Stanford iPhone Dev assignments along with the
> videos on iTunes.  And I'm stuck on the assignment for the first week.
>  Shoot!
> My goal is inspect each object of an array.  When I use isKindOfClass or
> isMemberOrClass, I do not get an expected YES or NO but rather a (null).
> Here is the relevant code:
>        NSMutableArray *myArray = [NSMutableArray arrayWithObjects:[NSURL
> URLWithString:@"AccountableTreeService.com"], @"Hello World",
> [NSProcessInfo processInfo], dictionary, mutableString, nil];
>        NSEnumerator *enumerator = [myArray objectEnumerator];
>        id step;
>        while (step = [enumerator nextObject]){
>                NSLog(@"");
>                NSLog(@"Class name: %@", [step className]);
>                NSLog(@"Is Member of NSURL: %@", [[step class]
> isMemberOfClass:[NSURL class]]);
>                NSLog(@"Is Kind of NSString: %@",);
>                NSLog(@"Responds to LowercaseString: ");//I'm still working
> on this part
>        }

In addition to what the others have mentioned, [[step class]
isKindOfClass:[NSString class]] is a nonsensical construction, as is
[[step class] isMemberOfClass:[NSURL class]]. -isKindOfClass: asks
whether the receiver (the thing you're sending it to, [step class] in
this case) is an *instance* of the class in question. In other words,
[[step class] isKindOfClass:[NSString class]] takes step's class, then
asks whether that class is an instance of NSString. The answer will
*always* be no.

You either want to write [step isKindOfClass:[NSString class]], or
write [[step class] isSubclassOfClass:[NSString class]]. They're
equivalent, but the former is less wordy and more clear.

For -isMemberOfClass:, the correct way is either [step
isMemberOfClass:[NSURL class]] or simply [step class] == [NSURL
class]. Note however that this query is rarely useful, as code should
always treat an instance of a subclass the same as an instance of a
superclass. In other words, your code shouldn't care whether 'step' is
an instance of NSURL itself or an instance of a subclass of NSURL.

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


Feed Parsing Framework ...

2009-05-21 Thread Mic Pringle
A week or two ago, a subscriber to this list announced a new framework
for parsing rss feeds.

I seem to have misplaced the email, and can't find the announcement on
CocoaBuilder.

Can anyone remember the link (I think it pointed to a Github repo) or
could the author perhaps come forward ?

Thanks

-Mic
___

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: Escaping white space in an NSString

2009-05-21 Thread Sherm Pendley
On Thu, May 21, 2009 at 2:26 AM, Bruce Johnson wrote:

> > Post your croaking code.  You seem to have some misapprehensions about
> how
> > command-line arguments work,
>

> No misapprehensions here.


Sorry, but I'm afraid there are.


> > What CLI were you planning to run on iPhone?
> The CLI is for a Cocoa App


There's no CLI at all in the code you posted.


> char  mdfile[PATHSIZE];
> strncpy(mdfile, , MAXREAD);
>
> FILE * stream = fopen(, "rt");
>
...

>
> So as you can see, a non-escaped, white space laden "pathToFile" will
> return a bogus FILE *stream.


No it won't. Spaces are only relevant to commands typed into a shell, or
used in a shell script. They're used by the shell to split its input into
the path to a command, and arguments to pass to it.

Spaces, and other characters that are meaningful when used in a shell, such
as <, >, &, $, or |, are of no importance whatsoever when passed to fopen.
No escaping or quoting is necessary.

To see what's really going on, try this immediately after your fopen:

if (NULL == stream)
NSLog(@"Could not open '%s': %s", pathToFile, strerror(errno));

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: How to disable application menu bar item

2009-05-21 Thread Graham Cox


On 21/05/2009, at 10:36 PM, Ashish Tiwari wrote:

I want to conditionally disable some items of my application menu  
bar for example "Format", "Insert" etc, so that user can not click  
on it and can not see its submenu.

When i do following:
[[[NSApp mainMenu] itemWithTitle:@"Insert"] setEnabled:NO];

Menu item "Insert" in menu bar still appears enabled but all items  
in its submenu get disabled. Basically my purpose is solved as user  
can not select any of sub menu items
but i want "Insert" itself to be disabled so that user can not even  
see its submenu.

Is it possible in Mac (Windows it can be done)?
If yes,  then How can i do so.



I believe the modern approach is not to do this. Menus are meant to  
act as a "road map" to the application and should be browsable and  
stable, with greying to indicate inappropriate choices.


The earlier Mac OS did allow title disabling, but one problem with it  
is being context sensitive, yet always visible, it wasn't always easy  
or efficient to update the title state in a timely fashion when the  
context changed (selections, etc). It seems OS X has deprecated this  
ability and nobody has missed it. You want your app to fit in, not  
stand out for the wrong reasons.


Don't forget that Windows copied the earlier Mac OS too...

--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: How to disable application menu bar item

2009-05-21 Thread Benjamin Dobson


On 21 May 2009, at 13:36:34, Ashish Tiwari wrote:


Hi All,

I want to conditionally disable some items of my application menu  
bar for example "Format", "Insert" etc, so that user can not click  
on it and can not see its submenu.

When i do following:
[[[NSApp mainMenu] itemWithTitle:@"Insert"] setEnabled:NO];

Menu item "Insert" in menu bar still appears enabled but all items  
in its submenu get disabled. Basically my purpose is solved as user  
can not select any of sub menu items
but i want "Insert" itself to be disabled so that user can not even  
see its submenu.

Is it possible in Mac (Windows it can be done)?
If yes,  then How can i do so.


Why?

It is explicitly against the Apple Human Interface Guidelines to  
prevent a user from seeing submenus, even if all of the items in the  
menu are disabled. Why go against it?


And I don't believe it can be done for menu bar items. It would look  
terrible, too.

___

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: Escaping white space in an NSString

2009-05-21 Thread Sherm Pendley
On Thu, May 21, 2009 at 1:23 AM, Bruce Johnson wrote:

> I have a unix path in an NSString via [[NSBundle bundleForClass: [self
> class]] pathForResource:  etc.. etc..
> The problem is that the path has white spaces scattered in the string.


That's not normally a problem.


> And I need to pass the unix path to a CLI application.  The CLI app
> croaks on the white spaces (for obvious reasons)


The reasons are not at all obvious. Whitespace is only a problem if you type
the whole command as a single string to a shell, which will split the string
on unescaped whitespace to find a command and arguments. Quoted strings are
also not split, so quoting user-provided arguments when they're used in
shell scripts is easier than escaping them.

If you're passing the arguments using NSTask, whitespace is not a problem.
In fact, adding unnecessary quotes and/or escapes to NSTask arguments will
*create* a problem, because NSTask - like everything *except* the command
shell - uses arguments exactly as given, without processing quotes or
escapes.

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


How to disable application menu bar item

2009-05-21 Thread Ashish Tiwari
Hi All,

I want to conditionally disable some items of my application menu bar for 
example "Format", "Insert" etc, so that user can not click on it and can not 
see its submenu.
When i do following:
[[[NSApp mainMenu] itemWithTitle:@"Insert"] setEnabled:NO];

Menu item "Insert" in menu bar still appears enabled but all items in its 
submenu get disabled. Basically my purpose is solved as user can not select any 
of sub menu items
but i want "Insert" itself to be disabled so that user can not even see its 
submenu.
Is it possible in Mac (Windows it can be done)?
If yes,  then How can i do so.

Thanks in advance.
Ashish
DISCLAIMER
==
This e-mail may contain privileged and confidential information which is the 
property of Persistent Systems Ltd. It is intended only for the use of the 
individual or entity to which it is addressed. If you are not the intended 
recipient, you are not authorized to read, retain, copy, print, distribute or 
use this message. If you have received this communication in error, please 
notify the sender and delete all copies of this message. Persistent Systems 
Ltd. does not accept any liability for virus infected mails.
___

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: Network Reachability APIs

2009-05-21 Thread Kirk Kerekes
I may have missed it, but I think that an essential point about the  
Reachability API has been left unmentioned: The OS Reachability API  
does its work without annoying the user -- something that is quite  
difficult to guarantee with roll-your-own versions. Believe it or not,  
there are still dial-up users out there, as well as many people using  
data cards that function like a modem. Software that is constantly  
causing those devices to connect without user prompting is going to be  
at least annoying.



___

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: Privilege elevation of a cocoa app

2009-05-21 Thread Jerry Krinock


On 2009 May 21, at 02:49, Arun wrote:

I have an application which when launched asks for user to  
authenticate for

admin rights.


Eyebrows are raised.

After user authenticates the app is launched. I thought after  
authentication
the Application executes with admin privilages. But is is still  
executing in

user privilages only.
Is there any way in which i can elevate the privilege of the  binary  
after

authentication.


You need to re-post this question to a different list where it will be  
on-topic:


http://lists.apple.com/mailman/listinfo/apple-cdsa

Also, from what I've read so far, prepare to be told that you're doing  
things wrong and that your application is a threat to national security.


___

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: NSTextView - Having to call setFrame twice to work?

2009-05-21 Thread Andy Lee
I get the same result using initWithFrame:, but if I use the  
designated initializer it works as expected:


textView = [[NSTextView alloc] initWithFrame:NSMakeRect(0, 0, 400,  
300) textContainer:nil];


The docs says that initWithFrame: creates a text container, so the  
difference seems to be whether the text view has a text container.  I  
don't understand exactly why this causes setFrame: to behave the way  
it does -- maybe someone else can shed light on this.


Note that sometimes setFrame: does set the frame to the size you give  
it -- for example, if you start with 400x900 and go to 500x800.


--Andy


On May 21, 2009, at 12:47 AM, Seth Willits wrote:


This is as simple as it gets...

textView = [[NSTextView alloc] initWithFrame:NSMakeRect(0, 0, 400,  
300)];


// [textView frame] is {0, 0, 400, 300}

[textView setFrame:NSMakeRect(100, 100, 500, 400)];

// [textView frame] is {100, 100, 500, 300}

[textView setFrame:NSMakeRect(100, 100, 500, 400)];

// [textView frame] is {100, 100, 500, 400}


What gives?


--
Seth Willits



___

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%40mac.com

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: Sensible way to extend base class?

2009-05-21 Thread Louis Gerbarg
As several people have mentioned, doing this kind of thing is very skanky,
and it won't work properly under GC without some additional machinery. But
if GC is not a concern you can do something that works with a bit grotesque
monkey patching.
The below code is generic, but it mucks with everything. I recommend you
always trim it down from NSObject to whatever class you are actually doing
it to.

Louis

#import 

#import 


@interface NSObject (LGAssociativeStorage)

@property (retain) id associatedObject;

@end

---


#import 

#import "LGAssociativeStorage.h"


/* We are using STL containers because:

   1) Using Objective C containers can cause deallocs which cause recursion
issues

   2) STL containers are high perf containers that don't introduce external
code dependencies

   Ideally one could include a thread safe map implementation, but I don't
need one currently

*/


#include 


typedef std::map idMap_t;

typedef std::pair idPair_t;


static NSMutableDictionary * data = nil;

static pthread_mutex_t data_lock = PTHREAD_MUTEX_INITIALIZER;

static IMP gOriginalNSObjectDealloc = nil;

static idMap_t associatedObjectMap;


static

void removeAssociatedObjectFromMap(id self) {

  idMap_t::iterator iter = associatedObjectMap.find(self);

if( iter != associatedObjectMap.end() ) {

[iter->second release];

associatedObjectMap.erase(iter);

}

}


static

id newNSObjectDealloc(id self, SEL deallocSelector, ...) {

pthread_mutex_lock(&data_lock);

removeAssociatedObjectFromMap(self);

pthread_mutex_unlock(&data_lock);

return gOriginalNSObjectDealloc(self, deallocSelector);

}


static void initIfNecessary(void) {

if (!data) {

data = [[NSMutableDictionary alloc] init];

 // The below line of code is abusive... in the future the Objective C
runtime will use it as evidence

// that I am an unfit software engineer and take custody of all my code

gOriginalNSObjectDealloc = class_replaceMethod([NSObject class], @selector(
dealloc), newNSObjectDealloc, "v@:");

}

}




@implementation NSObject (LGAssociativeStorage)


- (id) associatedObject {

id retval = nil;

pthread_mutex_lock(&data_lock);

initIfNecessary();

idMap_t::iterator iter = associatedObjectMap.find(self);

if( iter != associatedObjectMap.end() ) {

retval = iter->second;

}

pthread_mutex_unlock(&data_lock);

return retval;

}


- (void) setAssociatedObject:(id)object_ {

pthread_mutex_lock(&data_lock);

initIfNecessary();

removeAssociatedObjectFromMap(self);

[object_ retain];

associatedObjectMap.insert(idPair_t(self, object_));

pthread_mutex_unlock(&data_lock);

}


@end
___

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


problems with inspector window

2009-05-21 Thread Vitaly Ovchinnikov
Hello list,

I implemented inspector window like described here:
http://borkware.com/rants/inspectors/
and now have a problem. I use NSUndoManager to store undo/redo
information and if document is changed I can't close my inspector
window, it asks about saving document in its main window.
Is there any correct way to allow to close inspector window?

Thank you.
___

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

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

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

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


Best way to draw text in CAOpenGLLayer

2009-05-21 Thread Anshul jain

HI All,
		I am trying to scroll text in CAOpenGLLayer. Every thing is working  
fine. But the scrolling is not smooth and the CPU usage was 60 % -   
80%. I think application is taking time to convert NSString into a  
CGImage. Is there a better way of displaying text in CAOpenGLLayer.



This is how i am creating the CGBitmap context

- (void)setUpContext
{
CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
size_t  width, height, bytesPerRow;
CGDataProviderRef   bitmapContextDataProvider;
width = floor(self.bounds.size.width);
height = floor(self.bounds.size.height);
bytesPerRow = (width * 4 + 63) & ~63;
bitmapData = calloc(bytesPerRow * height, 1);
	bitmapContext = CGBitmapContextCreate(bitmapData, width, height,  
8 ,bytesPerRow, colorspace, kCGImageAlphaPremultipliedLast);
	graphicsContext = [[NSGraphicsContext  
graphicsContextWithGraphicsPort:bitmapContext flipped:NO] retain];
	bitmapContextDataProvider = CGDataProviderCreateWithData(nil,  
bitmapData, bytesPerRow * height, nil);

bitmapImage = CGImageCreate(width,  
height,
8,
32,
bytesPerRow,
colorspace,

kCGImageAlphaPremultipliedLast,

bitmapContextDataProvider,
nil,
false,

kCGRenderingIntentDefault);
CGDataProviderRelease(bitmapContextDataProvider);
CGColorSpaceRelease(colorspace);
}

this is how i am converting it to image

NSGraphicsContext   *previousContext = [NSGraphicsContext currentContext];
CGContextClearRect(bitmapContext,self.bounds);
[NSGraphicsContext setCurrentContext:graphicsContext];
NSRect rect = NSRectFromCGRect(self.bounds);
if (startCrawler) {
NSRect frameRect;
frameRect.size = NSMakeSize(0, self.frame.size.height - 10);
NSMutableDictionary *attributes = [NSMutableDictionary 
dictionary];
[attributes setObject:font forKey:NSFontAttributeName];
		[attributes setObject:textColor  
forKey:NSForegroundColorAttributeName];

for (int i =  0 ; i < [dispalyTitleArray count]  ; i++ ) {
			RSSDisplayItem *currentDisplayItem = [dispalyTitleArray  
objectAtIndex:i];
			frameRect.size.width = [currentDisplayItem size].width +  
kTextPadding;

frameRect.origin.x  = [currentDisplayItem xLocation];
			[[currentDisplayItem title] drawInRect:frameRect  
withAttributes:attributes];

}
}
[NSGraphicsContext setCurrentContext:previousContext];




Regards,
Anshul jain




Regards,
Anshul jain
Software Engineer

Prithvi Information Solutions Ltd
10Q3A1, Cyber Towers
HITEC City, Madhapur
Hyderabad - 500 081





___

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


Privilege elevation of a cocoa app

2009-05-21 Thread Arun
Hi All,

I have an application which when launched asks for user to authenticate for
admin rights.
After user authenticates the app is launched. I thought after authentication
the Application executes with admin privilages. But is is still executing in
user privilages only.
Is there any way in which i can elevate the privilege of the  binary after
authentication.

Thanks
Arun
___

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: Controlling some of CoreAnimation's more confusing automation

2009-05-21 Thread Andreas Grosam

On May 21, 2009, at 4:04 AM, Gwynne Raskind wrote:

I have a UIView that contains a number of CALayers. Nothing unusual  
here. The CALayers are subclassed to do their drawing, because that  
was easier than separating the delegate logic from my UIView  
subclass (since the view can't be the delegate of a sublayer - it  
causes an infinite recursion to do so, why isn't there a check for  
this somewhere in CA's or Cocoa Touch's code?).


Each time I call [anInstanceOfCALayer setNeedsDisplay], to update  
changes I've made to the layer's custom properties, Core Animation  
performs an implicit animation from the old cached data to the new  
draw state. For example, if I change a property so that my drawing  
code fills a path that was previously empty, the UI shows the filled  
space fading into existence.


I've figured out that I can explicitly disable this using the  
CATransaction calls wrapped around my call to -setNeedsDisplay. But  
I'd like to either:


1) animate the custom properties more directly with a  
CABasicAnimation. I tried this, but it did nothing at all.


2) get some control over the implicit animation CA is setting up for  
the contents transition. CATransaction only lets me set duration and  
the "is enabled" flag, whereas CAMediaTiming has a whole pile of  
useful parameters.


Any help would be appreciated.



Form your description, I can't see where the specific issue is. So I  
just post an example which will work (a modified working code, but  
changed for this example and not tested). Hope this helps:



I'm assuming you have a somewhat more complex layer hierarchy. Instead  
of subclassing a layer, I would define a "model" that has a visual  
representation in a UI. Say, this model is composed of a set of  
"shapes". But this design is up to you.


Instances of Shape are associated to a layer. It is assumed that a  
layer is only used by one shape. A Shape instance also has parameters  
which define a certain animation that will be triggered when a certain  
state change occurs on the instance:


Shape:
- (void) changeStateTo:(int)aState
{
// Calculate the effect of a state change:
// In this example it is a rotation of the shape, which will be  
visualized by a single animation

// that causes the layer to rotate:
// (get the current rotation of this shape in radians)
// (perform state change on the model)
CGFloat fromRotation = self.currentRotation;
[self private_changeStateTo:aState];
CGFloat toRotation = self.currentRotation;

// Create a rotation animation around z axis by using animation  
parameters hold by the Shape instance:

CABasicAnimation* animation = [CABasicAnimation animation];
animation.keyPath = @"transform.rotation.z";
animation.fromValue = [NSNumber numberWithFloat:fromRotation];
animation.toValue = [NSNumber numberWithFloat:toRotation];
animation.duration = (self.animationDuration);
animation.repeatCount = 0;

// Leave the presentation layer in its final state (preventing  
snap-back to original state),
// or in other words, match the state of the shape with its  
visual representation:

// (note: there are alternatives to accomplish this)
animation.removedOnCompletion = NO;
animation.fillMode = kCAFillModeBoth;

// Set a timing function (you may get required animation  
parameters from the Shape instance);
animation.timingFunction = [CAMediaTimingFunction  
functionWithName:kCAMediaTimingFunctionLinear];


// The delegate may handle CAAnimation delegate methods. The  
shape instance itself would be a

// good candidate to become the delegate:
animation.delegate = self;

// Add the animation to the shapes's layer. Note that this  
immediately causes the animation to

// start (asynchronously). setNeedsDisplay is not required!
// This will also stop a possibly running anmimation with the  
same key.

[self.layer addAnimation:animation forKey:self.name];
}


Of course, you can setup any animation type, or an animation group.

The layer associated to a shape may be part of a layer hierarchy.  
Setting up the layer hierarchy that models the visual representation  
of your set of (possibly hierarchically layered) shapes is a different  
thing though, and not shown.


The delegate methods can be used to determine when the animation  
starts and when it has been finished, and whether it has been   
interrupted by another animation.


This method can be called from any thread.

This design moves completely the "how to animate  a certain model  
state change" from the view controller to the many Shape classes that  
may exist in your application. So it can be easily extended by adding  
new sub classes of shape.



Regards
Andreas




-- Gwynne, Daughter of the Code
"This whole world is an asylum for the incurable."



___

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

Please do not post admin requests

Re: Unknown Host: Operation timed out Error

2009-05-21 Thread Shraddha Karwan
Hi,
The application which is running on iPhone Simulator crashes. And the
Debugger Console displays message "Unknown Host: Operation timed out".

On Fri, May 15, 2009 at 10:12 PM, Shawn Erickson  wrote:

> On Fri, May 15, 2009 at 6:40 AM, Shraddha Karwan
>  wrote:
> > Ok, but then what else could be the reason for the crash. The error
> message
> > is absolutely unexplainable. Also seems like not many developers have
> come
> > across this error. Am I missing out on some thing?
>
> Please provide us with more information.
>
> What do you mean by the following? Where do you see that message? What
> does the crash log, etc. look like for the crash?
>
> "But I get an error "Unknown Host: Operation timed out" on the debugger and
> the application crashes."
>
> -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: Binding 'Enabled' to NSObjectController.selection NSIsNotNil fails?

2009-05-21 Thread Quincey Morris

On May 20, 2009, at 22:35, Seth Willits wrote:

I have an NSObjectController whose Content item is bounds to an  
object's "thing" path. I can then bind the values of controls in my  
nib to model key paths through that NSObjectController in the usual  
way. Those Value bindings can use "Conditionally Sets Enabled" and  
they work great.


I have some controls where I'm not binding the Value though, and  
instead just need to bind Enabled alone, so that when there is no  
selection in the controller, those controls are disabled.


The obvious way of doing that is to bind 'Enabled' to the  
NSObjectController's "selection" controller key, (no model key), and  
use the value transformer NSIsNotNil. Anytime the selection is not  
nil, the control is enabled… right? It's super simple, but it  
doesn't work, and I don't see why not.


The documentation for [NSObjectController selection] says (in the  
discussion):


If a value requested from the selection proxy using key-value coding  
returns multiple objects, the controller has no selection, or the  
proxy is not key-value coding compliant for the requested key, the  
appropriate marker (NSMultipleValuesMarker, NSNoSelectionMarker or  
NSNotApplicableMarker) is returned. Otherwise, the value of the key  
is returned.


So nil is never returned (assuming none of the markers is defined to  
be nil).


You might try selectedObjects.count instead.


___

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

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

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

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


Re: Menu item with 'title' bound is always enabled. Bug?

2009-05-21 Thread Mike Abdullah
In my experience, binding menu bar items just isn't worth it. Use - 
validateMenu… or -validateUserInterfaceItem: to conditionally enable  
the menu and give it a good title. Otherwise you've got to manually  
keep track of the main window etc. yourself which is a waste of your  
time.


On 21 May 2009, at 02:21, Jerry Krinock wrote:

On a main menu item, I've set a delegate which implements - 
menuNeedsUpdate:.  In this method, I enable/disable some items and  
also modify some item titles based on current conditions.


With some items, however, instead of sending -setTitle: in - 
menuNeedsUpdate:, I had bound their 'title' in Interface Builder.   
But I just discovered that this 'title' binding was causing  
setEnabled:NO sent to these items during -menuNeedsUpdate: to be  
ignored.  A menu item with a 'title' bound is always enabled.


The fix is obvious -- don't bind any titles, set all titles in  
menuNeedsUpdate:.


But ain't this a bug?  (Mac OS 10.5.6)

___

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/cocoadev%40mikeabdullah.net

This email sent to cocoa...@mikeabdullah.net


___

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

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

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

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


Re: How to set dpi of an image

2009-05-21 Thread jonat...@mugginsoft.com


On 21 May 2009, at 08:29, Mahaboob wrote:


I need to save the image with respect to the given dpi.
I calculated the image size proportional to the dpi and saved it.
But when I'm viewing the dpi from preview it shows only 72 dpi.

I used the code like:

float compressionFactor = [compressionSlider floatValue];

NSDictionary *jpegProperties = [NSDictionary dictionaryWithObject:  
[NSNumber

numberWithFloat: compressionFactor] forKey: NSImageCompressionFactor];

   NSSize size = [image size];

   unsigned int resfac =  (unsigned int)[bitmapResolution  
intValue];




   [image setScalesWhenResized:YES];



   [image setSize:NSMakeSize(size.width * resfac/72, size.height *
resfac/72)];


setSize: doesn't change the underlying image reps
see the docs http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaDrawingGuide/Images/Images.html#/ 
/apple_ref/doc/uid/TP40003290-CH208-SW2


or this http://weblog.scifihifi.com/2005/06/25/how-to-resize-an-nsimage/

Apple has some decent sample code with CoreImage additions here
http://developer.apple.com/SampleCode/Reducer/listing16.html



   NSBitmapImageRep *theBmapRep = [NSBitmapImageRep imageRepWithData: 
[image

TIFFRepresentation]];

NSData *exportedData;

exportedData = [ theBmapRep representationUsingType:NSJPEGFileType
properties:jpegProperties];

Is it I'm missing something?
How can I set the exact dpi?

Thanks in advance
Mahaboob




___

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/jonathan%40mugginsoft.com

This email sent to jonat...@mugginsoft.com


Jonathan Mitchell

Central Conscious Unit
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


Apple Sample Code not working? SampleCMPlugin

2009-05-21 Thread Steve Cronin

Folks;

I'm making slow progress on what seems like should be a really simple  
contextual menu plugin.


Build the 2006 version of Apple's SampleCMPlugin (that's the latest I  
could find)


There is a section of code to determine if the current selection is  
text (or could be coerced to text):

...
static OSStatus WhoPastePluginExamineContext(void* thisInstance, const  
AEDesc* inContext, AEDescList* outCommandPairs ) {

...
if ( inContext ) {
AEDesc theAEDesc = { typeNull, NULL };
...
if ( AECoerceDesc( inContext, typeUTF8Text, &theAEDesc ) ==  
noErr ) {

...

Earlier versions of SampleCMPlugin used '(AECoerceDesc( inContext,  
typeChar, &theAEDesc )'


No matter what text I select this ALWAYS fails.  The plugin NEVER  
detects text correctly.
I have set up a generic coerce method and tested for both of these as  
well as:
typeUnicodeText, typeStyledText, typeIntlText, typeCFStringRef  (They  
all fail!)


I admit I'm on thin ice with the AECoerceDesc but it just seems like  
it shouldn't be this hard?
I'm using unmodified Apple sample code XC3.1.2 on 10.5.7 Intel  
(10.5 SDK deploy 10.4)


Can someone clarify how I can correctly determine whether there is  
text AND then how to actually obtain the text.

(No Cocoa allowed as this is a .c file!)

Thanks for any help!
Steve


___

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


How to set dpi of an image

2009-05-21 Thread Mahaboob
I need to save the image with respect to the given dpi.
I calculated the image size proportional to the dpi and saved it.
But when I'm viewing the dpi from preview it shows only 72 dpi.

I used the code like:

float compressionFactor = [compressionSlider floatValue];

NSDictionary *jpegProperties = [NSDictionary dictionaryWithObject: [NSNumber
numberWithFloat: compressionFactor] forKey: NSImageCompressionFactor];

NSSize size = [image size];

unsigned int resfac =  (unsigned int)[bitmapResolution intValue];



[image setScalesWhenResized:YES];



[image setSize:NSMakeSize(size.width * resfac/72, size.height *
resfac/72)];

   
NSBitmapImageRep *theBmapRep = [NSBitmapImageRep imageRepWithData:[image
TIFFRepresentation]];

NSData *exportedData;

exportedData = [ theBmapRep representationUsingType:NSJPEGFileType
properties:jpegProperties];

Is it I'm missing something?
How can I set the exact dpi?

Thanks in advance
Mahaboob

 


___

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: Escaping white space in an NSString

2009-05-21 Thread Seth Willits

On May 20, 2009, at 11:26 PM, Bruce Johnson wrote:

The CLI is for a Cocoa App, but I need to call this in both Leopard  
and iPhone


char  mdfile[PATHSIZE];
strncpy(mdfile, , MAXREAD);

FILE * stream = fopen(, "rt");


Nothing here is command-line related at all.




the rest of the c-code iterates over a rather large text file getting
a line at a time, (fgets(inbuff,MAXREAD,stream)) make some
calculations and then go onto the next line.

So as you can see, a non-escaped, white space laden "pathToFile" will
return a bogus FILE *stream.


M. no it won't. fopen, like pretty much every other  
function/method, takes an unescaped string. Your problem lies  
elsewhere, such as in not passing the right value to fopen. You  
mentioned you're getting that path in an NSString. You should be  
passing fopen the result of [string fileSystemRepresentation].




--
Seth Willits



___

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