Re: How to get finder type Open With dialog box

2009-04-29 Thread Kyle Sluder
On Wed, Apr 29, 2009 at 1:52 AM, Parimal Das parimal@webyog.com wrote:
 What i want to do is, when my code encounters a unknown file extension, it
 should open the finder type Open With dialog box for user to choose the
 app from the list.

There is no Open With dialog box, at least not one that's analogous
to Windows.  You can specify type associations in Finder, sure, but
the actual dialog used for selecting applications is just a standard
Open panel.

Run an NSOpenPanel modal for the type @com.apple.application.

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


NSButtonCell visibility binding in NSOutlineView

2009-04-29 Thread Chris Tracewell
I am looking for the best method of turning off the visibility of an  
NSButtonCell object for individual rows in an OutlineView/TableView. I  
have an OutlineView that is bound to a TreeController. There are two  
columns. In the last column I am using a checkbox cell that should  
only be visible to the user when a representedObject in the  
TreeController has a certain property value. There is no Visibility  
binding only Enabled which does not hide the control but just dims it.


I am using bindings to return a custom image for setImage and  
setAlternateImage to display a custom NSImage instead of the regular  
checkbox. It works nicely. I tried using conditional logic to return a  
transparent image when I want to hide the control but that affects the  
entire column. If I need to subclass I am suspecting I need to  
override NSTableColumn's dataCellForRow, but then how do I obtain the  
representedObject for that row?


Thanks for any help
___

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

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

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

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


Re: iphone SDK session duration

2009-04-29 Thread Bess Ho
Sorry for the delay in response. I'll need more help.

I follow suggestions on using applicationDidFinishLaunching: and
applicationWillTerminate: methods on AppDelegate.

It won't print NSLog when I stop the app on Console and throw errors when I
leave the app on simulator by pressing the home button to exist the app like
the device.

I didn't get any warnings or errors on building the project.

I used NSLog(@Session: %.1f, [now timeIntervalSinceDate:then]);

Please help!

*project code:*
http://code.google.com/p/iphonebuilder/downloads/list

- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Starting Session
}

- (void)applicationWillTerminate:(UIApplication *)application  {
// Ending Session
}

*Errors on console when I exit the app on simulator*

*** -[NSObject timeIntervalSinceReferenceDate]: unrecognized selector sent
to instance 0x521fe0
2009-04-28 17:07:32.283 sessiontime[22584:20b] CoreAnimation: ignoring
exception: *** -[NSObject timeIntervalSinceReferenceDate]: unrecognized
selector sent to instance 0x521fe0


On Wed, Apr 22, 2009 at 9:57 AM, Luke the Hiesterman luket...@apple.comwrote:

 What's wrong with the NSDate solution below?

 Luke

 On Apr 21, 2009, at 10:49 PM, Bess Ho wrote:

 I couldn't get any working responses from iphone developer forum or iphone
 meetup group. I am hoping that this group with more experience cocoa
 developers with understanding on MVC model, Xcode.

 On Tue, Apr 21, 2009 at 6:47 PM, Luke the Hiesterman 
 luket...@apple.comwrote:

 Sounds like you've already answered your question.

 Luke

 On Apr 21, 2009, at 4:00 PM, Bess Ho wrote:

  Is this appropriate mailing list to ask iphone SDK questions?

 How do you measure session duration on a utility application with 3
 ViewControllers?

 Use NSDate to mark the starting and ending the session and print the time
 lapsed on NSLog.

 --
 Bess Ho
 ___

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

 Please do not post 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/luketheh%40apple.com

 This email sent to luket...@apple.com





 --
 Bess Ho





-- 
Bess Ho
___

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

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

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

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


Re: Storing a table view in user defaults

2009-04-29 Thread Ryan Briones
On Tue, Apr 28, 2009 at 2:31 PM, Jerry Krinock je...@ieee.org wrote:


 On 2009 Apr 28, at 08:04, Ryan Briones wrote:

  My problem is that I have a table view that's bound
 to an array controller backed by user defaults in IB.


 I don't know what backed by means.


Sorry for not using the proper terminology. I have a table view whose
columns are bound to an array controller (Controller Key: arrangedObjects,
Model Key Path: name, etc) and the array controller is bound to shared user
defaults (Controller key: values, Model Key Path: arrayOfThings). Also I
have a button that send add: to the array controller and a button that sends
delete: and Enabled is bound to canRemove: on the array controller. Seems
like pretty standard setup from what I can tell.

When I click add, I get an empty row (selected) in the table view. I can
then double click on the row and edit the columns. If I click add again, the
first row is emptied out and the second row is selected and empty. If I exit
the application at this point and relaunch, the table view has 2 empty rows.

I hope this helps explain my problem better...Sorry for the confusion.


 The 'content' binding of your array controller should be bound to an
 NSUserDefaults object (labelled Shared Defaults by Interface Builder) with

   Controller Key = 'values'
   Model Key Path = keyToYourArrayInRootOfUserDefaults.

 ___

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

 Please do not post 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/ryan.briones%40brionesandco.com

 This email sent to ryan.brio...@brionesandco.com




-- 
Ryan Carmelo Briones
___

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

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

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

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


Re: Storing a table view in user defaults

2009-04-29 Thread Ryan Briones
Hey, thanks! I actually ran across your code last night when I was first
doing this. I ran your code and it worked fine. I created a test project to
copy your code, and mine failed. I tried looking at every checkbox and
every key path, nothing worked.
I've uploaded my the test project to github. I'd love it if you guys could
take a look, and tell me what I'm doing wrong. I feel like it's an exact
copy, but it doesn't work. Hopefully this can provide an insight into my
stupidity.

http://github.com/ryanbriones/tableview-userdefaults

If you don't have git, you can download a zip or tarball from the downloads
tab. Thanks!

On Tue, Apr 28, 2009 at 5:00 PM, Steven Riggs steven.ri...@me.com wrote:

 Check out the sample code here that demonstrates storing a dictionary in
 defaults with no code.
 http://idisk.mac.com/steven.riggs-Public?view=web

 I hope it helps...

 Steven Riggs



 On Apr 28, 2009, at 11:04 AM, Ryan Briones wrote:

  I'm a relative newb when it comes to cocoa programming, but I've been
 trying
 to finish of a project and put it out there so I can get some feedback and
 continue to get better. My problem is that I have a table view that's
 bound
 to an array controller backed by user defaults in IB. Adding a single new
 row works fine, but if I add any more, the data from the previous rows
 gets
 wiped out, but the actual rows get preserved. Further more, if I create a
 row and exit/relaunch the rows are persisted, but the data is not. If feel
 like I'm missing some important detail, but I can't figure out what. Any
 help is appreciated. Thanks.

 --
 Ryan Carmelo Briones
 ___

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

 Please do not post 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/steven.riggs%40me.com

 This email sent to steven.ri...@me.com





-- 
Ryan Carmelo Briones
___

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

Please do not post 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 make NSSplitView not dragable

2009-04-29 Thread Benjamin Dobson


On 28 Apr 2009, at 17:44:38, Ashish Tiwari wrote:


Hi All,

I have a horizontal NSSplitView, I want the splitter bar should  
remain in a fixed postion and user should not be able to change size  
of upper subview or lower subview by dragging it.

Note: Split bar should be visible but not be drag able.

Thanks,
Ashish


@implementation DisabledSplitView

- (void)awakeFromNib
{
[self setDelegate:self];
}

- (NSRect)splitView:(NSSplitView *)theSplitView effectiveRect: 
(NSRect)proposedEffectiveRect forDrawnRect:(NSRect)drawnRect  
ofDividerAtIndex:(NSInteger)dividerIndex

{
// Effectively disables splitter
return NSZeroRect;
}

- (void)drawDividerInRect:(NSRect)aRect
{
// Do nothing
}


@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


Re: C string constant-NSString constant without defining twice?

2009-04-29 Thread Uli Kusterer

On 28.04.2009, at 22:58, Erg Consultant wrote:
Except in the case where one line of code creates the temp file and  
then another immediately uses it and deletes is - as in my case.  
There is zero chance the user could FUS faster than my 2 lines of  
code create and delete the file.



 Wish that were true. You'd be surprised how fast some users manage  
to switch, or how a slow disk can cause the operation to pause long  
enough for FUS to be done.


 And even if that weren't the case, keep in mind that there are  
various ways (VNC, AppleScript etc.) how a user could trigger the  
action on a switched-out user as well. This is Unix, we have remote  
logins.


 Don't make assumptions just because you're lazy. Friends don't let  
friends hardcode absolute paths.


Cheers,
-- Uli Kusterer
The Witnesses of TeachText are everywhere...
http://www.zathras.de





___

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

Please do not post 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: NSButtonCell visibility binding in NSOutlineView

2009-04-29 Thread Kyle Sluder
On Tue, Apr 28, 2009 at 1:12 PM, Chris Tracewell ch...@thinkcl.com wrote:
 I am looking for the best method of turning off the visibility of an
 NSButtonCell object for individual rows in an OutlineView/TableView. I have
 an OutlineView that is bound to a TreeController. There are two columns. In
 the last column I am using a checkbox cell that should only be visible to
 the user when a representedObject in the TreeController has a certain
 property value. There is no Visibility binding only Enabled which does not
 hide the control but just dims it.

Hm.  I'm conflicted as to whether or not from a usability standpoint
you should prefer to display a disabled cell or none at all.

NSTableView has a -tableView:dataCellForTableColumn:row: delegate
method, so you don't need to subclass NSTableColumn.  Perhaps the
better approach is to subclass NSButtonCell and implement
-drawWithFrame:inView: somewhat like this:

-(void)drawWithFrame:(NSRect)frame inView:(NSView *)view {
  if([self shouldDisplayCheckboxForObject:[self objectValue]])
[super drawWithFrame:frame inView:view];
}

Then, of course, you need to implement
-shouldDisplayCheckboxForObject, set an instance of this cell as the
cell for your table column, and bind the column to your model objects
instead of an attribute thereof.

--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: iphone SDK session duration

2009-04-29 Thread Alexander Spohr

Luke already told you six hours before your post:

Am 29.04.2009 um 02:10 schrieb Bess Ho:

*** -[NSObject timeIntervalSinceReferenceDate]: unrecognized  
selector sent

to instance 0x521fe0
2009-04-28 17:07:32.283 sessiontime[22584:20b] CoreAnimation: ignoring
exception: *** -[NSObject timeIntervalSinceReferenceDate]:  
unrecognized

selector sent to instance 0x521fe0


You are asking an NSObject for timeIntervalSinceReferenceDate.
You need an NSDate. Your variable named now is NOT an NSDate.

atze

___

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

Please do not post 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


Crashing resetting or releasing an NSManagedObjectContext

2009-04-29 Thread Daniel Kennett

Hi list,

I'm hoping you guys can help me. I'm loading up a Core Data store,  
copying some data out and attempting to clear it all up. I use this  
code for my Quicklook plugin, and in parts of my app for previewing  
documents in a more advanced manner than Quicklook provides.


This is how I set up my ManagedObjectContext:

+(Pet *)petAtURL:(NSURL *)url {

	NSManagedObjectModel *managedObjectModel = 	 
[KNClarusQuickDocumentParser managedObjectModel];
	NSPersistentStoreCoordinator *coordinator =  
[[[NSPersistentStoreCoordinator alloc]  
initWithManagedObjectModel:managedObjectModel] autorelease];


[coordinator addPersistentStoreWithType:NSSQLiteStoreType
  configuration:nil
URL:url

options:nil
  
error:error];

NSManagedObjectContext *moc = [[NSManagedObjectContext alloc] init];
// ^ Not Autoreleasing here. It's the responsibility  of the  
caller to release the MOC. Autoreleasing causes crashes.


[moc setPersistentStoreCoordinator:coordinator];
[[moc undoManager] disableUndoRegistration];

NSError *fetchError = nil;
NSArray *fetchResults;
	NSFetchRequest *fetchRequest = [[[NSFetchRequest alloc] init]  
autorelease];


NSEntityDescription *entity = [NSEntityDescription entityForName:@Pet

  inManagedObjectContext:moc];
[fetchRequest setEntity:entity];
	fetchResults = [moc executeFetchRequest:fetchRequest  
error:fetchError];


if ((fetchResults != nil)  ([fetchResults count] == 1)   
(fetchError == nil))

{

NSManagedObject *pet = [[fetchResults objectAtIndex:0] retain];
return [pet autorelease];
}

return nil;

}


And this is how I get the data out and release it:

Pet *pet = [KNClarusQuickDocumentParser petAtURL:url];

// Copy out some data.

NSManagedObjectContext *context = [pet managedObjectContext];

if (context) {

[context reset]; // This call results in EXC_BAD_ACCESS
[context setPersistentStoreCoordinator:nil];
[context release];

}

return [dict autorelease];

 End code 

Different combinations of trying to do this right result in crashes at  
different points. Leaving out [context reset] and just releasing it  
obviously gives EXC_BAD_ACCESS again. Autoreleasing the MOC in  
+petAtURL: causes crashes when the autorelease pool pops. The only way  
I can get it to not crash is to -init the MOC and never release or  
autorelease it, but that's causing memory leaks!


Is there a good example anywhere of how to set up and tear down a Core  
Data document correctly?


 Thanks,

-- Daniel

 ___

   dan...@kennettnet.co.uk
   http://www.kennettnet.co.uk

Please include previous messages in any reply you send.



___

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

Please do not post 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: NSRunLoop vs. NSThread sleep

2009-04-29 Thread Alastair Houghton

On 29 Apr 2009, at 00:57, Eric Hermanson wrote:

When implementing the while-loop in the main function of an  
NSThread, is it correct to assume it is more efficient on the  
operating system to run the current run-loop until a specified date  
rather than just use NSThread sleepUntilDate to obtain the delay?


If you're talking about a secondary thread, NSThread's -sleepUntilDate  
is probably better.  But you don't even need to use that; you could  
use sleep() or nanosleep() or even select().


However...

 I ask because I don't really need a formal run loop or special  
input source as I'm just checking a shared queue for data (and the  
delay is to allow the thread to gracefully exit).


...you shouldn't be polling your shared queue, *unless* you have some  
real-time requirement that necessitates that architecture, *or* you're  
certain that, for the entire lifetime of your thread, the chances are  
that the queue will always be full by the time the thread gets to  
check it.  If you aren't sure you need to poll, you probably don't  
want to be polling.


What you should be doing instead is either using a semaphore or an  
NSConditionLock to set things up such that your thread doesn't run at  
all unless there's work to do.


 So it's simpler to code just the NSThread sleep, however, I am  
guessing that will cause me context switching performance issues and  
I'd be better off using the NSRunLoop?


If the NSRunLoop has nothing to do, I imagine it does the same thing  
anyway.


Finally, is it acceptable to use the NSThread's cancelled/ 
isCancelled mechanism to check for the thread-exit hint, rather than  
set/check a global variable in the NSThread threadDictionary (as  
Apple's documentation shows)?


That's what -cancel and -isCancelled are designed for.  That said, if  
I were implementing a thread to managed a work queue (which is what  
you're doing), I'd be inclined to override the default implementations  
so that they added an item to the work queue... that way the thread  
could block on the work queue and would wake up if someone sent - 
cancel to it.


But all of this is somewhat academic in a way, because Apple has  
handily provided NSOperationQueue for you which is probably what you  
should be using unless you have some backwards compatibility  
requirement or some other requirement that NSOperationQueue doesn't  
satisfy.


Kind regards,

Alastair.

--
http://alastairs-place.net



___

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

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

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

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


C language in obj-c

2009-04-29 Thread fawad shafi

Dear All,
may be this question is odd, but i wana use .obj file created in c language, in 
objective-c.
is it possible??
thanks in advance.

Regards,
Fawad Shafi



_
Rediscover Hotmail®: Now available on your iPhone or BlackBerry
http://windowslive.com/RediscoverHotmail?ocid=TXT_TAGLM_WL_HM_Rediscover_Mobile2_042009___

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

Please do not post 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: C string constant-NSString constant without defining twice?

2009-04-29 Thread Alastair Houghton

On 28 Apr 2009, at 21:58, Erg Consultant wrote:

Except in the case where one line of code creates the temp file and  
then another immediately uses it and deletes is - as in my case.  
There is zero chance the user could FUS faster than my 2 lines of  
code create and delete the file.


Honestly, I can think of lots of ways to get around that kind of thing  
(depending on exactly what I wanted to achieve).  It really, genuinely  
is a security hole, no matter how fast you think your program might be  
running (and it might be going much slower than you think for one  
reason or another).


Kind regards,

Alastair.

--
http://alastairs-place.net



___

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

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

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

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


Re: C string constant-NSString constant without defining twice?

2009-04-29 Thread Alastair Houghton

On 29 Apr 2009, at 01:33, Gwynne Raskind wrote:

[NSFileHandle initWithFileDescriptor:fileno(tmpfile())  
closeOnDealloc:NO]. Oops, now I have to keep track of the FILE* for  
as long as the NSFileHandle* exists.


Well you could use dup() to get around that, not that the above is the  
best thing to do anyway.


Kind regards,

Alastair.

--
http://alastairs-place.net



___

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

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

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

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


Re: C language in obj-c

2009-04-29 Thread Alastair Houghton

On 29 Apr 2009, at 11:04, fawad shafi wrote:

may be this question is odd, but i wana use .obj file created in c  
language, in objective-c.

is it possible??


It depends what you mean.  If you're asking if it's possible to use C  
code in a program that uses ObjC, of course.  Usually you'd include  
the C source code in your project and Xcode will just compile it for  
you when you hit Build.  Then you use the usual mechanisms to make use  
of your C code from your ObjC files (i.e. the extern keyword,  
function prototypes, header files and so on).


You can, of course, include C code in ObjC files directly, since ObjC  
is just a superset of the underlying C language.


If you are asking whether you can use .obj files built by (for  
instance) Microsoft's compiler, the answer is no.  Microsoft's .obj  
files use an extended form of COFF, whereas the .o files generated by  
OS X compilers use Mach-O, and while it's theoretically possible that  
you could convert a COFF file to Mach-O and feed it through the OS X  
linker, the platforms have different ABIs (calling conventions,  
structure layout conventions and the like) and so most likely it would  
just break.


If you're asking whether it's possible to include an object file in a  
project in a general sense, again the answer is yes.  You might need  
to feed the linker some additional arguments though, to make it link  
against the extra object.  However, as I say, the object file needs to  
be a Mach-O object and not (for instance) a Microsoft .obj file.


Kind regards,

Alastair.

p.s. This type of question is better addressed to xcode-dev.

--
http://alastairs-place.net



___

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

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

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

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


Re: C language in obj-c

2009-04-29 Thread Alastair Houghton

On 29 Apr 2009, at 11:25, Alastair Houghton wrote:


Kind regards,

Alastair.

p.s. This type of question is better addressed to xcode-dev.


Of course I meant xcode-users :-D

Kind regards,

Alastair.

--
http://alastairs-place.net



___

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

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

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

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


Re: C language in obj-c

2009-04-29 Thread Jean-Daniel Dupas


Le 29 avr. 09 à 12:04, fawad shafi a écrit :



Dear All,
may be this question is odd, but i wana use .obj file created in c  
language, in objective-c.

is it possible??
thanks in advance.


Obj-C is a superset of C and can access any C code just like you can  
from any other C file.


___

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

Please do not post 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: C language in obj-c

2009-04-29 Thread Alastair Houghton

On 29 Apr 2009, at 11:29, fawad shafi wrote:

for example i write one program in c language and then compile it,  
the compiler will create the one .obj file for us. if i wana use  
that obj file in xcode or obj-c, is it possible??


The system compiler on Mac OS X doesn't make files with the extension  
.obj, even for plain C code.  That's why I suspected you might be  
talking about some other compiler (my guess being Microsoft's, since  
that's the most common place where you might see a .obj extension).


Anyway, the easiest thing to do is to put your C source files into  
your Xcode project and it will compile them and link them against the  
rest of your program.  Then you don't need to bother about the object  
files at all.


Kind regards,

Alastair.

p.s. Please always reply to the list as well as directly.

--
http://alastairs-place.net



___

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

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

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

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


RE: C language in obj-c

2009-04-29 Thread fawad shafi

thanks for this useful info.
is it possible?
existing code that (possibly written in C) that we can easily port over to 
obj-c with minimum effort.

Regards,
Fawad Shafi




 CC: cocoa-dev@lists.apple.com
 From: alast...@alastairs-place.net
 To: fawadpaki_...@hotmail.com
 Subject: Re: C language in obj-c
 Date: Wed, 29 Apr 2009 11:33:54 +0100
 
 On 29 Apr 2009, at 11:29, fawad shafi wrote:
 
  for example i write one program in c language and then compile it,  
  the compiler will create the one .obj file for us. if i wana use  
  that obj file in xcode or obj-c, is it possible??
 
 The system compiler on Mac OS X doesn't make files with the extension  
 .obj, even for plain C code.  That's why I suspected you might be  
 talking about some other compiler (my guess being Microsoft's, since  
 that's the most common place where you might see a .obj extension).
 
 Anyway, the easiest thing to do is to put your C source files into  
 your Xcode project and it will compile them and link them against the  
 rest of your program.  Then you don't need to bother about the object  
 files at all.
 
 Kind regards,
 
 Alastair.
 
 p.s. Please always reply to the list as well as directly.
 
 -- 
 http://alastairs-place.net
 
 
 

_
Rediscover Hotmail®: Now available on your iPhone or BlackBerry
http://windowslive.com/RediscoverHotmail?ocid=TXT_TAGLM_WL_HM_Rediscover_Mobile2_042009___

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

Please do not post 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: C language in obj-c

2009-04-29 Thread Alastair Houghton

On 29 Apr 2009, at 11:35, Jean-Daniel Dupas wrote:


Le 29 avr. 09 à 12:25, Alastair Houghton a écrit :

Just for the record, with gcc-llvm, you can no longer assume that .o  
files are Mach-O object files.
When you use Link-Time-Optimization (or -O4) with llvm-gcc (or  
clang), it produces llvm bytecode (even if the output extension  
remain .o)


That's a good point.  They still aren't COFF though, and you can still  
link Mach-O objects with the LLVM bitcode.  Also, I haven't looked but  
it wouldn't surprise me to find that the .o files still had a Mach-O  
wrapper around the bitcode itself.


Kind regards,

Alastair.

--
http://alastairs-place.net



___

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

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

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

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


Re: NSRunLoop vs. NSThread sleep

2009-04-29 Thread Kyle Sluder
On Wed, Apr 29, 2009 at 6:00 AM, Alastair Houghton
alast...@alastairs-place.net wrote:
 But all of this is somewhat academic in a way, because Apple has handily
 provided NSOperationQueue for you which is probably what you should be using
 unless you have some backwards compatibility requirement or some other
 requirement that NSOperationQueue doesn't satisfy.

NSOperationQueue is broken:
http://www.mikeash.com/?page=pyblog/dont-use-nsoperationqueue.html

I am not under NDA at the moment, so I'll point out that 10.5.7 is
rumored to have fixes for NSOperationQueue.  If that bears out to be
true, then by all means run with NSOperationQueue.  If not, you might
want to hold off until Snow Leopard -- it wouldn't be the first time
that Apple engineers (or anyone else, for that matter) have tackled a
bug but missed some corner cases until the next major release.

--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: C language in obj-c

2009-04-29 Thread Jean-Daniel Dupas


Le 29 avr. 09 à 12:25, Alastair Houghton a écrit :


On 29 Apr 2009, at 11:04, fawad shafi wrote:

may be this question is odd, but i wana use .obj file created in c  
language, in objective-c.

is it possible??


It depends what you mean.  If you're asking if it's possible to use  
C code in a program that uses ObjC, of course.  Usually you'd  
include the C source code in your project and Xcode will just  
compile it for you when you hit Build.  Then you use the usual  
mechanisms to make use of your C code from your ObjC files (i.e. the  
extern keyword, function prototypes, header files and so on).


You can, of course, include C code in ObjC files directly, since  
ObjC is just a superset of the underlying C language.


If you are asking whether you can use .obj files built by (for  
instance) Microsoft's compiler, the answer is no.  Microsoft's .obj  
files use an extended form of COFF, whereas the .o files generated  
by OS X compilers use Mach-O


Just for the record, with gcc-llvm, you can no longer assume that .o  
files are Mach-O object files.
When you use Link-Time-Optimization (or -O4) with llvm-gcc (or clang),  
it produces llvm bytecode (even if the output extension remain .o)



___

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

Please do not post 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: C language in obj-c

2009-04-29 Thread Jean-Daniel Dupas


Le 29 avr. 09 à 12:39, Alastair Houghton a écrit :


On 29 Apr 2009, at 11:35, Jean-Daniel Dupas wrote:


Le 29 avr. 09 à 12:25, Alastair Houghton a écrit :

Just for the record, with gcc-llvm, you can no longer assume  
that .o files are Mach-O object files.
When you use Link-Time-Optimization (or -O4) with llvm-gcc (or  
clang), it produces llvm bytecode (even if the output extension  
remain .o)


That's a good point.  They still aren't COFF though, and you can  
still link Mach-O objects with the LLVM bitcode.  Also, I haven't  
looked but it wouldn't surprise me to find that the .o files still  
had a Mach-O wrapper around the bitcode itself.


In fact, they don't.
To handle these files, 'ld' try to load libLTO.dylib which works with  
llvm bytecode files directly.
You can even manipulate them using llvm tools (you can use llvm-dis on  
such .o file to get the corresponding llvm assembly for example).


___

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

Please do not post 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: C language in obj-c

2009-04-29 Thread jmunson

That depends upon the nature of the existing code...

Quoting fawad shafi fawadpaki_...@hotmail.com:



thanks for this useful info.
is it possible?
existing code that (possibly written in C) that we can easily port   
over to obj-c with minimum effort.


Regards,
Fawad Shafi





CC: cocoa-dev@lists.apple.com
From: alast...@alastairs-place.net
To: fawadpaki_...@hotmail.com
Subject: Re: C language in obj-c
Date: Wed, 29 Apr 2009 11:33:54 +0100

On 29 Apr 2009, at 11:29, fawad shafi wrote:

 for example i write one program in c language and then compile it,
 the compiler will create the one .obj file for us. if i wana use
 that obj file in xcode or obj-c, is it possible??

The system compiler on Mac OS X doesn't make files with the extension
.obj, even for plain C code.  That's why I suspected you might be
talking about some other compiler (my guess being Microsoft's, since
that's the most common place where you might see a .obj extension).

Anyway, the easiest thing to do is to put your C source files into
your Xcode project and it will compile them and link them against the
rest of your program.  Then you don't need to bother about the object
files at all.

Kind regards,

Alastair.

p.s. Please always reply to the list as well as directly.

--
http://alastairs-place.net





_
Rediscover Hotmail®: Now available on your iPhone or BlackBerry
http://windowslive.com/RediscoverHotmail?ocid=TXT_TAGLM_WL_HM_Rediscover_Mobile2_042009___

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

Please do not post 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/jmunson%40his.com

This email sent to jmun...@his.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: NSRunLoop vs. NSThread sleep

2009-04-29 Thread Alastair Houghton

On 29 Apr 2009, at 11:44, Kyle Sluder wrote:


On Wed, Apr 29, 2009 at 6:00 AM, Alastair Houghton
alast...@alastairs-place.net wrote:
But all of this is somewhat academic in a way, because Apple has  
handily
provided NSOperationQueue for you which is probably what you should  
be using
unless you have some backwards compatibility requirement or some  
other

requirement that NSOperationQueue doesn't satisfy.


NSOperationQueue is broken:
http://www.mikeash.com/?page=pyblog/dont-use-nsoperationqueue.html


Yes, it is, though I was under the impression that not everyone was  
seeing problems with it.  However, given the simpler sample program  
Mike put in the comments, it does look pretty borked to me.


Anyway, there's always

http://www.rogueamoeba.com/utm/2008/12/01/raoperationqueue-an-open-source-replacement-for-nsoperationqueue/ 



(for instance).

Kind regards,

Alastair.

--
http://alastairs-place.net



___

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

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

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

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


[OT] Re: C language in obj-c

2009-04-29 Thread Alastair Houghton

On 29 Apr 2009, at 11:36, fawad shafi wrote:


thanks for this useful info.
is it possible?
existing code that (possibly written in C) that we can easily port  
over to obj-c with minimum effort.


You don't need to port C code to ObjC.  ObjC is just C with some  
simple extensions.  Similarly, ObjC++ is just C++ with the same simple  
extensions.


The only problems you might have are things like non-portable  
assumptions in your code (e.g. structure layouts, byte ordering if  
you're targeting PPC machines as well as Intel, inline assembler) or  
places where your code isn't properly standards compliant.  Exactly  
how much trouble you have depends on how portable the original code was.


Just include the source files in your Xcode project, then hit Build.   
If you have errors at that point, you'll need to fix them.  You'll  
also need to test quite carefully if this code is coming from another  
platform.


Kind regards,

Alastair.

--
http://alastairs-place.net



___

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

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

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

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


It doesn't work without the NSLog()... Why?

2009-04-29 Thread Тимофей Даньшин

Hello.
It's a very funny thing. And i do hope i am not bonkers. But the  
following code works fine until i delete the line with NSLog().  
In the latter case it just returns an empty array. Are there any sane  
reasons why that can happen?


- (NSArray *) selectWordsBeginningWith:(NSString *) s {

	NSLog(@We do call SelectWordsBeginningWith); //- here is that  
line.

NSString *searchString = [NSString stringWithFormat:@%...@%@, s, 
@%%];
NSMutableArray *mutableRet = [[NSMutableArray alloc]init];

	[self intoArray:mutableRet addItemFromTable:@english  
usingStatement:readEnglish andSearchString:searchString];
	[self intoArray:mutableRet addItemFromTable:@russian  
usingStatement:readRussian andSearchString:searchString];


sqlite3_reset(readEnglish);
sqlite3_reset(readRussian);
NSArray *ret = [mutableRet copy];
//  NSLog(@The number of items to be returned is: %i, [ret count]);
[mutableRet release];
return ret;
}

Thank you in advance,
Timofey.
___

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

Please do not post 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: It doesn't work without the NSLog()... Why?

2009-04-29 Thread Kyle Sluder
2009/4/29 Тимофей Даньшин ok5.ad...@gmail.com:
 It's a very funny thing. And i do hope i am not bonkers. But the following
 code works fine until i delete the line with NSLog(). In the latter
 case it just returns an empty array. Are there any sane reasons why that can
 happen?

No, there is no sane reason for this behavior.  Though I remember
reading a story very recently somewhere in which someone had this
exact issue, and it had to do with the way that NSLog left the stack
when it completed.

You probably have a memory management or other issue somewhere,
perhaps in wherever is calling -selectWordsBeginningWith:.  But you
haven't posted nearly enough code to make even an educated guess.  You
need to post the code for
-intoArray:addItemFromTable:usingStatement:andSearchString: at the
very least.

--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: It doesn't work without the NSLog()... Why?

2009-04-29 Thread Graham Cox


On 29/04/2009, at 10:05 PM, Тимофей Даньшин wrote:


NSArray *ret = [mutableRet copy];
//  NSLog(@The number of items to be returned is: %i, [ret count]);
[mutableRet release];
return ret;



I don't see why your NSLog line should cause a problem, but your  
memory management at the end of the function is wrong, so may have a  
bearing on it.


Why copy mutableRet when you just release it anyway? Instead, just  
return it with an autorelease:


return [mutableRet autorelease];

There is no need to copy a mutable array just so you can return it as  
a non-mutable array - it is an array and its mutability is invisible  
to the client of this code. As it stands you're leaking the copy  
because it is never released.


--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: NSRunLoop vs. NSThread sleep

2009-04-29 Thread Michael Ash
On Wed, Apr 29, 2009 at 6:53 AM, Alastair Houghton
alast...@alastairs-place.net wrote:
 On 29 Apr 2009, at 11:44, Kyle Sluder wrote:

 On Wed, Apr 29, 2009 at 6:00 AM, Alastair Houghton
 alast...@alastairs-place.net wrote:

 But all of this is somewhat academic in a way, because Apple has handily
 provided NSOperationQueue for you which is probably what you should be
 using
 unless you have some backwards compatibility requirement or some other
 requirement that NSOperationQueue doesn't satisfy.

 NSOperationQueue is broken:
 http://www.mikeash.com/?page=pyblog/dont-use-nsoperationqueue.html

 Yes, it is, though I was under the impression that not everyone was seeing
 problems with it.  However, given the simpler sample program Mike put in the
 comments, it does look pretty borked to me.

It appears that the reason not everybody can reproduce the problem is
because the bug is hardware-dependent. Thus this fact won't save you
unless your code won't ever escape your machine (or 10.5.7 fixes it,
or you only support 10.6 and that fixes it).

 Anyway, there's always

 http://www.rogueamoeba.com/utm/2008/12/01/raoperationqueue-an-open-source-replacement-for-nsoperationqueue/

 (for instance).

Note that although this is of course the best code ever (ahem) it is
not equally capable compared to NSOperationQueue. (It mostly does
less, but has some extra capabilities as well.) However for what the
poster is after it's probably a good fit, since it's basically a fancy
worker thread.

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: It doesn't work without the NSLog()... Why?

2009-04-29 Thread Тимофей Даньшин
Why copy mutableRet when you just release it anyway? Instead, just  
return it with an autorelease:
I do that because i return an immutable array. I always try to return  
the types i promise to return in the declaration :)


To Kyle:
I looked at the - 
intoArray:addItemFromTable:usingStatement:andSearchString:, but i  
failed to find anything bad in there. Here is the code:


- (void) intoArray:(NSMutableArray *)mutableRet addItemFromTable: 
(NSString *)table usingStatement:(sqlite3_stmt *)statement  
andSearchString:(NSString *) searchString {


	sqlite3_bind_text(statement, 1, [searchString  
cStringUsingEncoding:NSUTF8StringEncoding], -1, SQLITE_TRANSIENT);


while (sqlite3_step(statement) == SQLITE_ROW) {
		NSString *s = [NSString stringWithUTF8String:(char *)  
sqlite3_column_text(statement, 0)];

int wid = sqlite3_column_int(statement, 1);
		[mutableRet addObject:[WordIdAndDatabase makeWithId:wid word:s  
andDatabaseName:table]];

}
}

And here is some more detailed description of the problem. The thing  
is that i have a class called Database which is responsible for  
communicating with my database. The Database class is controlled by a  
DatabaseManager, which is a singleton... Any object in my application  
wanting to get anything from the db calls the [DatabaseManager  
sharedManager] and calls the methods it needs to call.


As I may have mentioned before, the app I am writing is a dictionary.  
The user interface has an NSTableView and an NSTextField. As the user  
types a searchword into the textfield, the app creates new  
NSOperations that select the words beginning with the chars the user  
has typed, from the database, and then i show them in the table view.  
Again, all the interactions with the db are executed via the  
DatabaseManager.


When the user hits enter or clicks on a cell with a word in it, we  
select that word with the equivalent from the db and display that in a  
different window.


And the thing is that when the NSLog line we talked above is not  
there, the -selectWordsBeginningWith: method works fine only until the  
user presses Enter or clicks a cell, i.e. until we get another class  
connect to the database.


Again, with NSLog in place, it all works fine no mater how many  
translations you open...


I would be really grateful for any hints to what the cause might be.




On Apr 29, 2009, at 4:32 PM, Graham Cox wrote:



On 29/04/2009, at 10:05 PM, Тимофей Даньшин wrote:


NSArray *ret = [mutableRet copy];
//  NSLog(@The number of items to be returned is: %i, [ret count]);
[mutableRet release];
return ret;



I don't see why your NSLog line should cause a problem, but your  
memory management at the end of the function is wrong, so may have a  
bearing on it.


Why copy mutableRet when you just release it anyway? Instead, just  
return it with an autorelease:


return [mutableRet autorelease];

There is no need to copy a mutable array just so you can return it  
as a non-mutable array - it is an array and its mutability is  
invisible to the client of this code. As it stands you're leaking  
the copy because it is never released.


--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: It doesn't work without the NSLog()... Why?

2009-04-29 Thread Michael Ash
2009/4/29 Тимофей Даньшин ok5.ad...@gmail.com:
 Hello.
 It's a very funny thing. And i do hope i am not bonkers. But the following
 code works fine until i delete the line with NSLog(). In the latter
 case it just returns an empty array. Are there any sane reasons why that can
 happen?

Does it break if you delete the NSLog and run it in the debugger? If
so, step through the code until you find the place where it's going
wrong, and fix it.

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: It doesn't work without the NSLog()... Why?

2009-04-29 Thread Graham Cox


On 29/04/2009, at 10:48 PM, Тимофей Даньшин wrote:

Why copy mutableRet when you just release it anyway? Instead, just  
return it with an autorelease:
I do that because i return an immutable array. I always try to  
return the types i promise to return in the declaration :)





Even so, you're leaking the copy because it should be returned  
autoreleased, as per correct memory management rules. The fact that  
you're not doing this here suggests that memory management may be  
flaky elsewhere, as Kyle suggested.


However, returning the mutable array when your method promises a non- 
mutable array is perfectly OK. NSMutableArray is an NSArray and  
therefore the method has fulfilled its contract. If the client code  
then tests its class and discovers that it is in fact mutable after  
all, and mutates it, then the client code is the bad guy here. All the  
copy does is waste time, and serves no purpose. Still, if it makes you  
feel better...




Note that:

- (NSArray *) selectWordsBeginningWith:(NSString *) s;

Does not include the word new, alloc, copy or mutableCopy and  
therefore the caller does not own the array returned.





--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: iphone SDK session duration

2009-04-29 Thread Bess Ho
I did reply. Moderator on this list rejected because my reply is too long. I
was about to report the results. I get it to work. I open source the Xcode
project code on google project if anyone want it.

On Wed, Apr 29, 2009 at 12:57 AM, Alexander Spohr a...@freeport.de wrote:

 Luke already told you six hours before your post:

 Am 29.04.2009 um 02:10 schrieb Bess Ho:

  *** -[NSObject timeIntervalSinceReferenceDate]: unrecognized selector sent
 to instance 0x521fe0
 2009-04-28 17:07:32.283 sessiontime[22584:20b] CoreAnimation: ignoring
 exception: *** -[NSObject timeIntervalSinceReferenceDate]: unrecognized
 selector sent to instance 0x521fe0


 You are asking an NSObject for timeIntervalSinceReferenceDate.
 You need an NSDate. Your variable named now is NOT an NSDate.

atze




-- 
Bess Ho
___

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

Please do not post 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 keyboard focus to in NSView in Carbon Application?

2009-04-29 Thread xue zhiy
I create a custom NSView in my Carbon Application.  For embed it into  
Carbon window, i create a HICocoaview for it.


My question is:  How to set keyboard focus to the NSView?

I can get the focus after i mouse click the NSView. I try to set focus  
by SetKeyboardFocus( windowRef,  pHICocoaView,  
kControlFocusNextPart ). But it doesn't work.



HIViewRef pHICocoaView;
NSView* pView = [[MyCustomNSView alloc] initWith: this];
HICocoaViewCreate(pView, 0, pHICocoaView);

HIViewAddSubview(pContentView, mpHICocoaView);


Thanks for you help.

Sincerely ,
Bruce




___

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

Please do not post 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 Display Names

2009-04-29 Thread Cédric Luthi
 Perfect! Thank you. Is this documented anywhere? Not even IORegistryExplorer
 appears to display this dictionary.

There is no technote documenting the procedure, but both
IODisplayCreateInfoDictionary and CGDisplayIOServicePort are in public
headers, so it is safe to use.
___

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

Please do not post 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: Why is NSString-FSRef so hard?

2009-04-29 Thread Mark Douma


On Apr 28, 2009, at 1:34 AM, Erg Consultant wrote:


  if( glBundle ) {
   // Get main bundle info dict...

   d = [ glBundle infoDictionary ];
   if( d ) {
   // Get the GL bundle's path from the info dict...
z = [ d objectForKey:kNSBundleInitialPathInfoDictKey ];
   if( z ) {
   // Break the path up into a path component array...
arr = [ z  
componentsSeparatedByString:kSlashStringKey ];

// Make a mutable path string to manipulate...
m = [ NSMutableString stringWithCapacity:0 ];
   }
   }
   }

   if( m  arr ){
   for(i=0; i[ arr count] - 1; i++ ) {
   [m appendString:[arr objectAtIndex:i] ];
   [m appendString:@/ ];
   }
//go up one level to get at Info.plist
[m appendString:@Info.plist ];
dd = [ NSDictionary dictionaryWithContentsOfFile:m ];
zzz = [ dd valueForKey:@CFBundleExecutable ];
//reset
[ m setString:@ ];
//Loop again appening all path compoents to final file to  
launch...


   for(i=0; i[ arr count] - 1; i++ ) {
   [m appendString:[arr objectAtIndex:i] ];
   [m appendString:@/ ];
   }
//now get full path to the file we want to actually run...
[ m appendString:zzz ];
[ m appendString:@.ifn ];



Wow, you are making this problem way, way harder than it needs to  
be. ;-)


If you are working with file paths, you shouldn't be using  
componentsSeparatedByString:, nor should you be defining / to be the  
component you should be separating by. What if someone had your app  
inside of a folder they named Apps/Utilities? The HFS+ filesystem  
actually uses a colon as the path separator, so having a / in the name  
of a file or folder is perfectly acceptable, but would likely cause a  
headache and unexpected results if your code were to encounter it. (Go  
to the Finder and try adding a /).


When dealing with file paths, you should be using the following methods:

+ (NSString *)pathWithComponents:(NSArray *)components;

- (NSArray *)pathComponents;

- (NSString *)lastPathComponent;
- (NSString *)stringByDeletingLastPathComponent;
- (NSString *)stringByAppendingPathComponent:(NSString *)str;

- (NSString *)pathExtension;
- (NSString *)stringByDeletingPathExtension;
- (NSString *)stringByAppendingPathExtension:(NSString *)str;

- (NSString *)stringByStandardizingPath;


Note that these aren't in the NSString.h header itself, but in a  
separate NSPathUtilities.h file.


Using these higher-level commands will insulate you from even having  
to worry about what the path separator even is (it will be handled for  
you). The same goes for adding a filename extensions: [fileName  
stringByAppendingString:@.jpg] should be [fileName  
stringByAppendingPathExtension:@jpg].***


Hope this helps,

Mark



*** Adobe developers, this means you! Maybe then I wouldn't have a  
folder in my user library folder whose name is Application Support/ 
Adobe/Acrobat.



---
Mark Douma
Grand Rapids, MI, USA
mdoum...@mac.com
http://homepage.mac.com/mdouma46/
---




___

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

Please do not post 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


Localizing Without Xcode UI

2009-04-29 Thread Michael Hanna
I'm adding localized nibs in Xcode 3.1 by Get Info... on the nib, and
clicking Add Localization... this is working as expected but rather
slow. Is there a faster way?

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: It doesn't work without the NSLog()... Why?

2009-04-29 Thread Graham Cox


On 29/04/2009, at 10:48 PM, Тимофей Даньшин wrote:

- (void) intoArray:(NSMutableArray *)mutableRet addItemFromTable: 
(NSString *)table usingStatement:(sqlite3_stmt *)statement  
andSearchString:(NSString *) searchString {





Also, I don't mean to pick on your code (there's nothing obviously  
wrong with what you've posted so far apart from the leak I mentioned  
already), but as a matter of style, this way of designing methods is a  
bit strange. In the interests of being as self-contained and clean as  
possible, I'd rearrange this method something like this:


- (NSArray*) itemsFromTableWithName:(NSString*) table sqlStatement: 
(sqlite3_stmt*) statement searchString:(NSString*) searchString;


This way the method stands alone with a fully defined and self- 
documenting purpose that can be called by anyone without having first  
to create a NSMutableArray to pass into it. If they want to accumulate  
the results into a further array, then fine, do that; if they don't,  
they haven't had to create an array just to keep your code happy.  
There are also fewer failure modes, because this code is responsible  
for creating the returned array, and not relying on the client to do  
so. It's also easier for the client to detect success or failure,  
because a returned empty or nil array could mean something. In your  
case, the client would have to examine the contents of the array  
before and after to figure out if anything had actually happened.


This design is widely seen throughout the Cocoa frameworks, whereas  
the intoArray: type thing you have I don't think I've ever seen. It's  
usually a good plan to follow the approaches used in the frameworks,  
they are for good reason.


--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: Crashing resetting or releasing an NSManagedObjectContext

2009-04-29 Thread Keary Suska

On Apr 29, 2009, at 2:59 AM, Daniel Kennett wrote:

Different combinations of trying to do this right result in crashes  
at different points. Leaving out [context reset] and just releasing  
it obviously gives EXC_BAD_ACCESS again. Autoreleasing the MOC in  
+petAtURL: causes crashes when the autorelease pool pops. The only  
way I can get it to not crash is to -init the MOC and never release  
or autorelease it, but that's causing memory leaks!


The most common cause if this error is an over-release. Turn on  
zombies and see who (if any) is being over-released. The culprit could  
be in your copy data code, that you don't provide. There doesn't  
seem to be anything obviously wrong (other than explained below), that  
I can see.


Is there a good example anywhere of how to set up and tear down a  
Core Data document correctly?


I can say that the design you present is flawed according to OOP  
rules, specifically how you release the managed object context. An  
object should never release an object it doesn't own or has retained.  
I understand why you are doing this--I am just saying it is a flawed  
approach.


I don't know what the KNClarusQuickDocumentParser class does in its  
entirety, but it may call for a singleton pattern or at least a shared  
object pattern (not a proper pattern name AFAIK, just mentioning the  
technique, for instance, [NSNotificationCenter defaultCenter]).


Tear down, in your case, should be as simple as releasing the MOC. The  
other calls (-reset etc) are unnecessary.


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

___

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

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

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

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


Re: NSButtonCell visibility binding in NSOutlineView

2009-04-29 Thread Ashley Clark

On Apr 28, 2009, at 12:12 PM, Chris Tracewell wrote:

I am looking for the best method of turning off the visibility of an  
NSButtonCell object for individual rows in an OutlineView/TableView.  
I have an OutlineView that is bound to a TreeController. There are  
two columns. In the last column I am using a checkbox cell that  
should only be visible to the user when a representedObject in the  
TreeController has a certain property value. There is no Visibility  
binding only Enabled which does not hide the control but just dims it.


I am using bindings to return a custom image for setImage and  
setAlternateImage to display a custom NSImage instead of the regular  
checkbox. It works nicely. I tried using conditional logic to return  
a transparent image when I want to hide the control but that affects  
the entire column. If I need to subclass I am suspecting I need to  
override NSTableColumn's dataCellForRow, but then how do I obtain  
the representedObject for that row?


Why not just implement - 
outlineView:willDisplayCell:forTableColumn:item: on your delegate and  
then set your images there depending on what item is about to be  
displayed?



Ashley
___

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

Please do not post 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: Crashing resetting or releasing an NSManagedObjectContext

2009-04-29 Thread Alexander Spohr

Daniel,

You are trying to fetch an object and keep it - but you want to  
ignore / throw away the NSManagedObjectContext. This will never work.  
The NSManagedObjectContext keeps the object. Your Pet can not exist  
without its NSManagedObjectContext.


You should let the caller provide a NSManagedObjectContext and fetch  
your Pet into that context. Make it the callers responsibility to get  
a NSManagedObjectContext not yours.
+ (Pet *)petAtURL:(NSURL *)url inContext:(NSManagedObjectContext  
*)aManagedObjectContext


Or copy the pet into something like an NSDictionary and return that.

atze



Am 29.04.2009 um 10:59 schrieb Daniel Kennett:


Hi list,

I'm hoping you guys can help me. I'm loading up a Core Data store,  
copying some data out and attempting to clear it all up. I use this  
code for my Quicklook plugin, and in parts of my app for previewing  
documents in a more advanced manner than Quicklook provides.


This is how I set up my ManagedObjectContext:

+(Pet *)petAtURL:(NSURL *)url {

	NSManagedObjectModel *managedObjectModel = 	 
[KNClarusQuickDocumentParser managedObjectModel];
	NSPersistentStoreCoordinator *coordinator =  
[[[NSPersistentStoreCoordinator alloc]  
initWithManagedObjectModel:managedObjectModel] autorelease];


[coordinator addPersistentStoreWithType:NSSQLiteStoreType
  configuration:nil
URL:url

options:nil
  
error:error];

NSManagedObjectContext *moc = [[NSManagedObjectContext alloc] init];
   // ^ Not Autoreleasing here. It's the responsibility  of the  
caller to release the MOC. Autoreleasing causes crashes.


[moc setPersistentStoreCoordinator:coordinator];
[[moc undoManager] disableUndoRegistration];

NSError *fetchError = nil;
NSArray *fetchResults;
	NSFetchRequest *fetchRequest = [[[NSFetchRequest alloc] init]  
autorelease];


	NSEntityDescription *entity = [NSEntityDescription  
entityForName:@Pet


  inManagedObjectContext:moc];
[fetchRequest setEntity:entity];
	fetchResults = [moc executeFetchRequest:fetchRequest  
error:fetchError];


   if ((fetchResults != nil)  ([fetchResults count] == 1)   
(fetchError == nil))

{

NSManagedObject *pet = [[fetchResults objectAtIndex:0] retain];
return [pet autorelease];
}

return nil;

}


And this is how I get the data out and release it:

Pet *pet = [KNClarusQuickDocumentParser petAtURL:url];

// Copy out some data.

NSManagedObjectContext *context = [pet managedObjectContext];

if (context) {

[context reset]; // This call results in EXC_BAD_ACCESS
[context setPersistentStoreCoordinator:nil];
[context release];

}

return [dict autorelease];

 End code 

Different combinations of trying to do this right result in crashes  
at different points. Leaving out [context reset] and just releasing  
it obviously gives EXC_BAD_ACCESS again. Autoreleasing the MOC in  
+petAtURL: causes crashes when the autorelease pool pops. The only  
way I can get it to not crash is to -init the MOC and never release  
or autorelease it, but that's causing memory leaks!


Is there a good example anywhere of how to set up and tear down a  
Core Data document correctly?


Thanks,

-- Daniel

___

  dan...@kennettnet.co.uk
  http://www.kennettnet.co.uk

Please include previous messages in any reply you send.



___

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

Please do not post 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/atze%40freeport.de

This email sent to a...@freeport.de


___

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

Please do not post 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


NSTableView: Type selecting in one column but not another

2009-04-29 Thread Eric Gorr
I was wondering if it was possible to get finer control over what type  
selecting searches in a row.


I have two columns in my table which both contain text. It only makes  
sense to match what the user is typing to the text found in the first  
column.


Unfortunately, I cannot seem to find a way to disable type selection  
on the second column. It seems to be an all-or-nothing feature.


I am certain I could handle this myself by disabling the feature and  
then modifying the key down method to do the right thing, but was  
hoping I had missed something.

___

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

Please do not post 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: NSTableView: Type selecting in one column but not another

2009-04-29 Thread I. Savant
On Wed, Apr 29, 2009 at 11:43 AM, Eric Gorr mail...@ericgorr.net wrote:
 I was wondering if it was possible to get finer control over what type
 selecting searches in a row.

 I have two columns in my table which both contain text. It only makes sense
 to match what the user is typing to the text found in the first column.

 Unfortunately, I cannot seem to find a way to disable type selection on the
 second column. It seems to be an all-or-nothing feature.

  Have you read the documentation? The
-tableView:typeSelectStringForTableColumn:row: method documentation
says:

Return Value
A string that is used in type select comparison for row and
tableColumn. Return nil if the row or tableColumn should not be
searched.

--
I.S.
___

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

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

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

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


Re: NSTableView: Type selecting in one column but not another

2009-04-29 Thread Ashley Clark

On Apr 29, 2009, at 10:43 AM, Eric Gorr wrote:

I was wondering if it was possible to get finer control over what  
type selecting searches in a row.


I have two columns in my table which both contain text. It only  
makes sense to match what the user is typing to the text found in  
the first column.


Unfortunately, I cannot seem to find a way to disable type selection  
on the second column. It seems to be an all-or-nothing feature.


I am certain I could handle this myself by disabling the feature and  
then modifying the key down method to do the right thing, but was  
hoping I had missed something.


Implement -tableView:typeSelectStringForTableColumn:row: on your  
delegate and only return a value for the columns you're interested in  
having type select work with.



Ashley

___

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

Please do not post 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: NSTableView: Type selecting in one column but not another

2009-04-29 Thread Eric Gorr

On Apr 29, 2009, at 12:05 PM, Ashley Clark wrote:


On Apr 29, 2009, at 10:43 AM, Eric Gorr wrote:

I was wondering if it was possible to get finer control over what  
type selecting searches in a row.


I have two columns in my table which both contain text. It only  
makes sense to match what the user is typing to the text found in  
the first column.


Unfortunately, I cannot seem to find a way to disable type  
selection on the second column. It seems to be an all-or-nothing  
feature.


I am certain I could handle this myself by disabling the feature  
and then modifying the key down method to do the right thing, but  
was hoping I had missed something.


Implement -tableView:typeSelectStringForTableColumn:row: on your  
delegate and only return a value for the columns you're interested  
in having type select work with.


Ah. Thank you. Don't know how I missed that.
___

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

Please do not post 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: NSButtonCell visibility binding in NSOutlineView [SOLVED]

2009-04-29 Thread Chris Tracewell

Kyle,

Thanks for the reply. Yes I know and agree on the issue of the  
usability. I struggled with this but ultimately felt it was essential  
as other options disassociated the property from the object too much  
or made it appear that a given object could indeed have the property  
enabled.


What I made work, and feels like the best solution is to use was a OV  
delegate I had missed. It's nice as it requires no custom drawing and  
allows me to inspect the object. It took one IBOutlet to bind to the  
column I wanted to modify.


-(NSCell *)outlineView:(NSOutlineView *)outlineView  
dataCellForTableColumn:(NSTableColumn *)tableColumn item:(id)item

{
	if (tableColumn == myAttributeColumn  !item representedObject]  
representedObject] myType] isEqualToString:@style])

{
return [NSTextFieldCell new];
}

return [tableColumn dataCellForRow:item];
}


 Chris

On Apr 29, 2009, at 12:04 AM, Kyle Sluder wrote:

On Tue, Apr 28, 2009 at 1:12 PM, Chris Tracewell ch...@thinkcl.com  
wrote:

I am looking for the best method of turning off the visibility of an
NSButtonCell object for individual rows in an OutlineView/ 
TableView. I have
an OutlineView that is bound to a TreeController. There are two  
columns. In
the last column I am using a checkbox cell that should only be  
visible to

the user when a representedObject in the TreeController has a certain
property value. There is no Visibility binding only Enabled which  
does not

hide the control but just dims it.


Hm.  I'm conflicted as to whether or not from a usability standpoint
you should prefer to display a disabled cell or none at all.

NSTableView has a -tableView:dataCellForTableColumn:row: delegate
method, so you don't need to subclass NSTableColumn.  Perhaps the
better approach is to subclass NSButtonCell and implement
-drawWithFrame:inView: somewhat like this:

-(void)drawWithFrame:(NSRect)frame inView:(NSView *)view {
 if([self shouldDisplayCheckboxForObject:[self objectValue]])
   [super drawWithFrame:frame inView:view];
}

Then, of course, you need to implement
-shouldDisplayCheckboxForObject, set an instance of this cell as the
cell for your table column, and bind the column to your model objects
instead of an attribute thereof.

--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: Group Identity Programming

2009-04-29 Thread Jessica Billings
 The third thing I tried is getting the gid using:
 gid_t curGroupID = getgid(); OR
 int curGroupID = getgid();
 CBGroupIdentity *groupIdentity = [CBGroupIdentity
 groupIdentityWithPosixGID:curGroupID authority:[CBIdentityAuthority
 defaultIdentityAuthority]];

 When I try to show the gid using NSLog, it hangs the program. When I
 show
 the groupIdentity object, it returns (null).

The above is better. What does the debugger show for curGroupID? There
is no reason to hang on NSLog if for curGroupID, as it is really juts
an unsigned int. What is the NSLog code you are using?

Thank you for your help!

The reason NSLog was hanging is that I was using the wrong formatting token.
When I use:

NSLog(@current group id: %i, curGroupID);

I get current group id: 1612776775, which I'm assuming is right. However,
I am still getting Current group info: (null) when I do:

CBGroupIdentity *groupIdentity = [CBGroupIdentity
groupIdentityWithPosixGID:curGroupID authority:[CBIdentityAuthority
defaultIdentityAuthority]];
NSLog(@Current group info: %@, groupIdenditity);

Unfortunately, I don't know if solving this problem will solve my ultimate
problem (although I'm sure it will help!). My ultimate problem is that I
have a number of group identities chosen by the identity picker. I need to
look at their member lists and see if the logged-in user is in any of those
lists. What I can't figure out is how to get access to the member lists of
the groups that I get using the identity picker. I think this has to do with
the fact that the identity picker returns CBIdentity objects, but how would
one make a CBGroupIdentity object using the information from the CBIdentity
object for a particular group identity? The only way I can see to make a
CBGroupIdentity object is using the above code, but as the documentation
says:

The getgid() function returns the real group ID of the calling process ...
The real group ID is specified at login time.
The real group ID is the group of the user who invoked the program.

What group is this referring to? If I made a local test_group and put the
user in that, would it be the gid of test_group? What if the user is an
many groups, both local and managed? This is the heart of my problem.
___

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

Please do not post 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: NSButtonCell visibility binding in NSOutlineView

2009-04-29 Thread Chris Tracewell


On Apr 29, 2009, at 8:13 AM, Ashley Clark wrote:


On Apr 28, 2009, at 12:12 PM, Chris Tracewell wrote:

I am looking for the best method of turning off the visibility of  
an NSButtonCell object for individual rows in an OutlineView/ 
TableView. I have an OutlineView that is bound to a TreeController.  
There are two columns. In the last column I am using a checkbox  
cell that should only be visible to the user when a  
representedObject in the TreeController has a certain property  
value. There is no Visibility binding only Enabled which does not  
hide the control but just dims it.


I am using bindings to return a custom image for setImage and  
setAlternateImage to display a custom NSImage instead of the  
regular checkbox. It works nicely. I tried using conditional logic  
to return a transparent image when I want to hide the control but  
that affects the entire column. If I need to subclass I am  
suspecting I need to override NSTableColumn's dataCellForRow, but  
then how do I obtain the representedObject for that row?


Why not just implement - 
outlineView:willDisplayCell:forTableColumn:item: on your delegate  
and then set your images there depending on what item is about to be  
displayed?



Ashley


I tried that by setting the image but I need 3 states for the checkbox  
- OFF, ON, HIDDEN. Whenever I set a certain row to a HIDDEN image to  
hide that row it would affect the image for all other items too. So it  
looked like I would need to subclass, however I found the solution and  
just posted about it before your email came in...


-(NSCell *)outlineView:(NSOutlineView *)outlineView  
dataCellForTableColumn:(NSTableColumn *)tableColumn item:(id)item



Thanks

Chris
___

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

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

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

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


Re: NSButtonCell visibility binding in NSOutlineView [SOLVED]

2009-04-29 Thread Corbin Dunn


On Apr 29, 2009, at 9:31 AM, Chris Tracewell wrote:


Kyle,

Thanks for the reply. Yes I know and agree on the issue of the  
usability. I struggled with this but ultimately felt it was  
essential as other options disassociated the property from the  
object too much or made it appear that a given object could indeed  
have the property enabled.


What I made work, and feels like the best solution is to use was a  
OV delegate I had missed. It's nice as it requires no custom drawing  
and allows me to inspect the object. It took one IBOutlet to bind to  
the column I wanted to modify.


-(NSCell *)outlineView:(NSOutlineView *)outlineView  
dataCellForTableColumn:(NSTableColumn *)tableColumn item:(id)item

{
	if (tableColumn == myAttributeColumn  !item  
representedObject] representedObject] myType]  
isEqualToString:@style])

{
return [NSTextFieldCell new];
}

return [tableColumn dataCellForRow:item];
}



This is not a fully correct solution. Your code as-is will leak lots  
of memory (unless you are creating a GC app, in which case it won't  
have good performance due to creating too many cells). You probably  
want to use -willDisplayCell to reset or properly setup your state for  
the cells.


-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


NSOperation, Sqlite, library routine called out of sequence

2009-04-29 Thread Тимофей Даньшин

Hello again.

In short, i get an error calling the same synchronized singleton  
DatabaseManager from different threads.


Here is what I am actually doing. As I was writing earlier, i am  
writing a dictionary application that is supposed to show translations  
for words from the database. In the main window, there is a tableview  
and a textfield. As a user types a word, i create a new NSOperation  
that calls the [DatabaseManager  sharedManager] and calls the methods  
to select all the words beginning with the letters the user has typed.  
And then the tableview is filled with the words so selected.


That works ok until the user presses return to see the translation of  
the word he has typed. That action also calls the [DatabaseManager  
sharedManager] and calls the methods for selecting the whole article  
from the db. This results in the library routine called out of  
sequence error in sqlite. Selecting an article from the db worked  
perfectly well when it was not called after the procedure described  
above.


And when, after receiving an empty dictionary article, the user begins  
typing a new word in the search textfield, nothing happens with the  
tableview, and sqlite3_step function calls end with the library  
routine called out of sequence error.


Here are the relevant excerpts from the classes involved.

Database:

- (NSArray *) selectWordsBeginningWith:(NSString *) s {
NSString *searchString = [NSString stringWithFormat:@%...@%@, s, 
@%%];
	NSMutableArray *mutableRet = [self itemsFromTable:@english  
usingStatement:readEnglish andSearchString:searchString];
	NSMutableArray *arr2 = [self itemsFromTable:@russian  
usingStatement:readRussian andSearchString:searchString];


[mutableRet addObjectsFromArray: arr2];

sqlite3_reset(readEnglish);
sqlite3_reset(readRussian);
NSArray *ret = [[mutableRet copy] autorelease];

return ret;
}


- (NSDictionary *) selectArticleWithId: (WordIdAndDatabase *)  
articleId {

sqlite3_stmt *currentOne;

if ([articleId.datbaseName isEqualToString:@english]) {
currentOne = selectArticleEnglishToRussian;
} else {
currentOne = selectArticleRussianToEnglish;
}

NSString *originalWord = articleId.word;
sqlite3_bind_int(currentOne, 1, articleId.wordId);
NSMutableArray *translations = [[NSMutableArray alloc] init];

while (sqlite3_step(currentOne) == SQLITE_ROW) {
		[translations addObject:[NSString stringWithUTF8String:(char *)  
sqlite3_column_text(currentOne, 0)]];

}

	NSLog(@There may be an error in the db things: %s,  
sqlite3_errmsg(database));


	NSDictionary *ret = [NSDictionary  
dictionaryWithObjectsAndKeys:originalWord, @original, translations,  
@translations, nil];

[translations release];

sqlite3_reset(currentOne);
return ret;
}

- (NSMutableArray *) itemsFromTable:(NSString *)table usingStatement: 
(sqlite3_stmt *)statement andSearchString:(NSString *) searchString {


	NSMutableArray *mutableRet = [[[NSMutableArray alloc] init]  
autorelease];
	sqlite3_bind_text(statement, 1, [searchString  
cStringUsingEncoding:NSUTF8StringEncoding], -1, SQLITE_TRANSIENT);

while (sqlite3_step(statement) == SQLITE_ROW) {
		NSString *s = [NSString stringWithUTF8String:(char *)  
sqlite3_column_text(statement, 0)];

int wid = sqlite3_column_int(statement, 1);
		[mutableRet addObject:[WordIdAndDatabase makeWithId:wid word:s  
andDatabaseName:table]];

}

	NSLog(@There MIGHT BE an error in getting things from the db: %s,  
sqlite3_errmsg(database));

return mutableRet;
}

Thank you for your attention.

Timofey.
___

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

Please do not post 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: NSButtonCell visibility binding in NSOutlineView

2009-04-29 Thread Ashley Clark

On Apr 29, 2009, at 11:46 AM, Chris Tracewell wrote:


On Apr 29, 2009, at 8:13 AM, Ashley Clark wrote:


On Apr 28, 2009, at 12:12 PM, Chris Tracewell wrote:

I am looking for the best method of turning off the visibility of  
an NSButtonCell object for individual rows in an OutlineView/ 
TableView. I have an OutlineView that is bound to a  
TreeController. There are two columns. In the last column I am  
using a checkbox cell that should only be visible to the user when  
a representedObject in the TreeController has a certain property  
value. There is no Visibility binding only Enabled which does not  
hide the control but just dims it.


I am using bindings to return a custom image for setImage and  
setAlternateImage to display a custom NSImage instead of the  
regular checkbox. It works nicely. I tried using conditional logic  
to return a transparent image when I want to hide the control but  
that affects the entire column. If I need to subclass I am  
suspecting I need to override NSTableColumn's dataCellForRow, but  
then how do I obtain the representedObject for that row?


Why not just implement - 
outlineView:willDisplayCell:forTableColumn:item: on your delegate  
and then set your images there depending on what item is about to  
be displayed?


I tried that by setting the image but I need 3 states for the  
checkbox - OFF, ON, HIDDEN. Whenever I set a certain row to a HIDDEN  
image to hide that row it would affect the image for all other items  
too. So it looked like I would need to subclass, however I found the  
solution and just posted about it before your email came in...


-(NSCell *)outlineView:(NSOutlineView *)outlineView  
dataCellForTableColumn:(NSTableColumn *)tableColumn item:(id)item


When using willDisplayCell you have to set the image for all rows to  
whatever the image should be for that row.


Something along the lines of:

if (rowShouldBeHidden) {
[cell setImage:nil];
[cell setAlternateImage:nil];
}
else {
[cell setImage:normalImage];
[cell setAlternateImage:alternateImage];
}


Ashley
___

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

Please do not post 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: Group Identity Programming

2009-04-29 Thread Kyle Sluder
On Wed, Apr 29, 2009 at 9:36 AM, Jessica Billings
slaveofosi...@gmail.com wrote:
 What group is this referring to? If I made a local test_group and put the
 user in that, would it be the gid of test_group? What if the user is an
 many groups, both local and managed? This is the heart of my problem.

Users in UNIX have a single primary group and potentially multiple
secondary groups.  The real gid of a user is that user's primary
group, unless it's been changed by setgid.

--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: Group Identity Programming

2009-04-29 Thread Greg Guerin

Jessica Billings wrote:


My ultimate problem is that I
have a number of group identities chosen by the identity picker. I  
need to
look at their member lists and see if the logged-in user is in any  
of those
lists. What I can't figure out is how to get access to the member  
lists of
the groups that I get using the identity picker. I think this has  
to do with
the fact that the identity picker returns CBIdentity objects, but  
how would
one make a CBGroupIdentity object using the information from the  
CBIdentity

object for a particular group identity?



CBGroupIdentity is a subclass of CBIdentity.  So in the NSArray of  
CBIdentity items returned from the identity picker, you test whether  
each item is a CBGroupIdentity or not using the normal Objective-C  
mechanism:


 [someItem isKindOfClass:CBGroupIdentity]

Once you've identified a CBGroupIdentity, then type-cast it to  
(CBGroupIdentity*).  Then test whether the CBIdentity of the current  
user is a member of that group using the -members method and  
searching the resulting NSArray.  The search should be recursive,  
since I saw nothing prohibiting nested membership, only a prohibition  
against circular membership.


Of course, if the array of CBIdentity's from the identity picker  
doesn't contain any groups, then the user isn't going to be a member  
of any of them, and you search the identity picker's NSArray for  
CBIdentity presence.  If that sounds like a recursive search of a  
group's -members NSArray, it is.


To me, the problem doesn't seem to have anything to do with group  
identity per se.  It seems to hinge entirely on the subclass/ 
superclass relationship, and identifying specific subclass types.


It's possible I've made an error in the above.  I only spent a few  
minutes reading the class docs and Identity Services Programming  
Guide, and without looking any further, this seems like the simplest  
thing that might work.


  -- 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: CA -animator animation only works the first time

2009-04-29 Thread Benjamin Stiglitz
On Tue, Apr 28, 2009 at 02:49:23PM -0700, Erg Consultant wrote:
 I have two standard Cocoa objects in my window that I animate using CA's 
 AppKit -animator method. When my nib loads, I get the original NSRects of the 
 two items by sending them the -frame message. I then recalc the rects to move 
 the two views offscreen.
 
 When I show my window, I animate both views back into the window thusly:
 
 [ [ oudWindowIconView animator ] setFrame:destGameIconRect ];
 
 [ [ oudWinowLogoImage animator ] setFrame:destLogoRect ];
 
 This works fine - the first time. The next time I show my window and the same 
 code runs, the two items are not visible in the window.
 
 The dest rects of the reanimated views are the same as the original view 
 rects when the nib loads.
 
 So why does the animation work only the first time?

-awakeFromNib will only be called once, when the window is loaded from
the NIB. You need to reset the view positions in the code that actually
displays the window.

-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: NSOperation, Sqlite, library routine called out of sequence

2009-04-29 Thread Greg Guerin

Тимофей Даньшин wrote:

In short, i get an error calling the same synchronized singleton  
DatabaseManager from different threads.



Are you sure your database accesses are synchronized (i.e. thread- 
safe)? I see nothing in the posted code that uses @synchronized or  
any other locking mechanism.


  -- 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: NSOperation, Sqlite, library routine called out of sequence

2009-04-29 Thread Тимофей Даньшин
The DatabaseManager is synchronized. If any class is to communicate  
with the db, it does that through the DatabaseManager. The latter just  
provides proxy methods. I think, that should result in classes getting  
the instance of the DatabaseManager only when it is no longer (or not  
yet) used by other classes.


+ (DatabaseManager*)sharedManager {
@synchronized(self) {
if (sharedDatabaseManager == nil) {
[[self alloc] init]; // assignment not done here
}
}
return sharedDatabaseManager;
}

+ (id)allocWithZone:(NSZone *)zone {
@synchronized(self) {
if (sharedDatabaseManager == nil) {
sharedDatabaseManager = [super allocWithZone:zone];
[sharedDatabaseManager initDb];
return sharedDatabaseManager;
}
}
return nil;
}


On Apr 29, 2009, at 10:52 PM, Greg Guerin wrote:


Тимофей Даньшин wrote:

In short, i get an error calling the same synchronized singleton  
DatabaseManager from different threads.



Are you sure your database accesses are synchronized (i.e. thread- 
safe)? I see nothing in the posted code that uses @synchronized or  
any other locking mechanism.


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

This email sent to ok5.ad...@gmail.com


___

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

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

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

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


Re: NSOperation, Sqlite, library routine called out of sequence

2009-04-29 Thread Greg Guerin

Тимофей Даньшин wrote:

The DatabaseManager is synchronized. If any class is to communicate  
with the db, it does that through the DatabaseManager. The latter  
just provides proxy methods. I think, that should result in classes  
getting the instance of the DatabaseManager only when it is no  
longer (or not yet) used by other classes.



But that does nothing to prevent multiple threads from performing  
additional concurrent actions on the database.  It's not enough to  
just control access to the shared singleton, if the actions performed  
by the singleton aren't also thread-safe.  All the queries, updates,  
etc. need thread-safety, too.


  -- 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: NSOperation, Sqlite, library routine called out of sequence

2009-04-29 Thread Тимофей Даньшин

Hm...
That really works! Thanks a lot.

Putting the bodies of those methods in @synchronized(self) blocks helped

Thanks a lot again.

On Apr 29, 2009, at 11:33 PM, Greg Guerin wrote:


Тимофей Даньшин wrote:

The DatabaseManager is synchronized. If any class is to communicate  
with the db, it does that through the DatabaseManager. The latter  
just provides proxy methods. I think, that should result in classes  
getting the instance of the DatabaseManager only when it is no  
longer (or not yet) used by other classes.



But that does nothing to prevent multiple threads from performing  
additional concurrent actions on the database.  It's not enough to  
just control access to the shared singleton, if the actions  
performed by the singleton aren't also thread-safe.  All the  
queries, updates, etc. need thread-safety, too.


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

This email sent to ok5.ad...@gmail.com


___

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

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

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

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


Re: Binding question

2009-04-29 Thread Ken Thomases

On Apr 28, 2009, at 5:09 AM, Arun wrote:

For the first table i have used the an array in my controller and  
this array

has been set as content array in the ArrayController object.
Now when i double click in need to bind the table in the sheet to  
the the
subjectDetails array. I am not able to figure out how to set the  
binding

for the second table.
Any ideas?


You need a second array controller.  Its content should be bound to  
the first array controller, with controller key selection, and model  
key path subjectDetails.  You bind the table columns in the detail  
view (the sheet) to this second array controller.


Look up master-detail interface in Apple's guides for more in-depth  
description of this technique.


There are also some examples here: 
http://homepage.mac.com/mmalc/CocoaExamples/controllers.html

Cheers,
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: Group Identity Programming

2009-04-29 Thread Keary Suska

On Apr 29, 2009, at 7:36 AM, Jessica Billings wrote:


The third thing I tried is getting the gid using:
gid_t curGroupID = getgid(); OR
int curGroupID = getgid();
CBGroupIdentity *groupIdentity = [CBGroupIdentity
groupIdentityWithPosixGID:curGroupID authority:[CBIdentityAuthority

defaultIdentityAuthority]];



When I try to show the gid using NSLog, it hangs the program. When I

show
the groupIdentity object, it returns (null).


The above is better. What does the debugger show for curGroupID?  
There

is no reason to hang on NSLog if for curGroupID, as it is really juts
an unsigned int. What is the NSLog code you are using?


Thank you for your help!

The reason NSLog was hanging is that I was using the wrong  
formatting token.

When I use:

NSLog(@current group id: %i, curGroupID);

I get current group id: 1612776775, which I'm assuming is right.  
However,

I am still getting Current group info: (null) when I do:


That is certainly an odd GID, but I suppose it could be. Leopard  
changed everything again, so who knows. Anyway, remember that there is  
no correspondence between the Unix user/group management and the Mac  
OS X system user management. It is possible that the Unix-based means  
of acquiring UIDs and GIDs doesn't work with the Mac's way of doing  
things.


Check your values against what you expect them to be. To get the UID  
and GID for a user, right-click on the user in the system accounts  
pane (system prefs), choosing advanced options. I would also check  
the getuid() call and see if it returns the expected UID. This will  
tell you whether the C calls know about Mac user handling.



CBGroupIdentity *groupIdentity = [CBGroupIdentity
groupIdentityWithPosixGID:curGroupID authority:[CBIdentityAuthority
defaultIdentityAuthority]];
NSLog(@Current group info: %@, groupIdenditity);

Unfortunately, I don't know if solving this problem will solve my  
ultimate
problem (although I'm sure it will help!). My ultimate problem is  
that I
have a number of group identities chosen by the identity picker. I  
need to
look at their member lists and see if the logged-in user is in any  
of those
lists. What I can't figure out is how to get access to the member  
lists of
the groups that I get using the identity picker. I think this has to  
do with
the fact that the identity picker returns CBIdentity objects, but  
how would
one make a CBGroupIdentity object using the information from the  
CBIdentity
object for a particular group identity? The only way I can see to  
make a
CBGroupIdentity object is using the above code, but as the  
documentation


If the getgid/getuid functions don't work, I don't know what to tell  
you. You could try digging into the new user management system (man  
dscl), or NSTask to the id utility (man id).


HTH,

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

___

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

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

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

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


Re: File Reading Problems

2009-04-29 Thread Ken Thomases

On Apr 28, 2009, at 9:19 PM, Pierce Freeman wrote:


- (void)awakeFromNib
{
   NSFileHandle *remoteConnection = [NSFileHandle
fileHandleForReadingAtPath:@/Users/user/Desktop/file.plist];


The above does not promise to keep the NSFileHandle object around for  
as long as you need it.  It's not at all clear to me that - 
readToEndOfFileInBackgroundAndNotify retains the file handle for its  
duration.


So, you need to manage the lifetime of the file handle by retaining it  
here and releasing it when you know you're done with it.




   [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(readAllTheData:)
name:NSFileHandleReadToEndOfFileCompletionNotification
object:remoteConnection];
   [remoteConnection readToEndOfFileInBackgroundAndNotify];

}

- (void)readAllTheData:(NSNotification *)note {
   NSString *errors = nil;
   NSData *contentsOfDockFile = [note object];
   NSLog(@%@, contentsOfDockFile);
   NSDictionary *testing = [NSPropertyListSerialization
propertyListFromData:contentsOfDockFile
mutabilityOption:NSPropertyListImmutable format:nil
errorDescription:errors];
   NSLog(@%@, testing);

   [[NSNotificationCenter defaultCenter] removeObserver:self
name:NSFileHandleReadToEndOfFileCompletionNotification object:[note
object]];

   [testing release];
}



On Apr 28, 2009, at 10:15 PM, Pierce Freeman wrote:


I added [testing retain] after the declaration of
the variable, and I no longer get the wheel of death and my app  
freezing up.


This smacks of flailing without understanding.

The problem with your original code is that -propertyListFromData:...  
gives you an object, but does not give you the right/responsibility  
for releasing it, and yet you were releasing it anyway.


While it is technically correct to solve this by adding [testing  
retain], it is redundant.  You could have just removed your [testing  
release].  The object is guaranteed to live at least until you return  
out of your -readAllTheData: method, so you need not retain it.  And,  
if you don't retain it, you should not release it.


All this is to concur with Adam's suggestion that you reread the  
memory management guide.


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: NSButtonCell visibility binding in NSOutlineView

2009-04-29 Thread Chris Tracewell


On Apr 29, 2009, at 10:59 AM, Ashley Clark wrote:


On Apr 29, 2009, at 11:46 AM, Chris Tracewell wrote:


On Apr 29, 2009, at 8:13 AM, Ashley Clark wrote:


On Apr 28, 2009, at 12:12 PM, Chris Tracewell wrote:

I am looking for the best method of turning off the visibility of  
an NSButtonCell object for individual rows in an OutlineView/ 
TableView. I have an OutlineView that is bound to a  
TreeController. There are two columns. In the last column I am  
using a checkbox cell that should only be visible to the user  
when a representedObject in the TreeController has a certain  
property value. There is no Visibility binding only Enabled which  
does not hide the control but just dims it.


I am using bindings to return a custom image for setImage and  
setAlternateImage to display a custom NSImage instead of the  
regular checkbox. It works nicely. I tried using conditional  
logic to return a transparent image when I want to hide the  
control but that affects the entire column. If I need to subclass  
I am suspecting I need to override NSTableColumn's  
dataCellForRow, but then how do I obtain the representedObject  
for that row?


Why not just implement - 
outlineView:willDisplayCell:forTableColumn:item: on your delegate  
and then set your images there depending on what item is about to  
be displayed?


I tried that by setting the image but I need 3 states for the  
checkbox - OFF, ON, HIDDEN. Whenever I set a certain row to a  
HIDDEN image to hide that row it would affect the image for all  
other items too. So it looked like I would need to subclass,  
however I found the solution and just posted about it before your  
email came in...


-(NSCell *)outlineView:(NSOutlineView *)outlineView  
dataCellForTableColumn:(NSTableColumn *)tableColumn item:(id)item


When using willDisplayCell you have to set the image for all rows to  
whatever the image should be for that row.


Something along the lines of:

if (rowShouldBeHidden) {
[cell setImage:nil];
[cell setAlternateImage:nil];
}
else {
[cell setImage:normalImage];
[cell setAlternateImage:alternateImage];
}


Ashley



Ashley,

Thank you - that worked. I thought I had tried something similar but I  
obviously had it wrong. Here is a screen shot for reference if anyone  
cares to see the window in final state and has any comments.


http://www.thinkcl.com/images/screengrab.png

Chris
___

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

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

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

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


Re: Core Data Fetches + Transient Properties + NSPredicateEditor = Sadness

2009-04-29 Thread Jerry Krinock

Thanks to Kyle and Melissa for the further explanation.

So, I thought about it some more and agree with you that putting a few  
redundant bits on the disk is not sinful, and actually I am a fan of  
keyPathsForValuesAffectingValueForkey.  Look at the little script I  
have in my Xcode scripts menu! [1]


But the other issue -- the inability of a Core Data fetch to handle  
arbitrary predicates produced by NSPredicateEditor -- weighs heavily  
against Core Data fetches.  I made my own simple predicate editor  
control a few years ago, but of course it is a pile of garbage  
compared to NSPredicateEditor, and I just can't go back to 2006 now.   
So I still plan to use NSPredicateEditor, fetch all and filter with - 
[NSArray filteredArrayWithPredicate:].


I have used sqlite3 directly myself and don't recall any limitation on  
the number of ALL, ANY or IN clauses.  If there is not, then maybe  
Apple would be responsive to a enhancement/bug report on Core Data  
fetches not being able to handle predicates from NSPredicateEditor.   
And if I'm lucky Apple will fix it before any of my users has a data  
set large enough to require hard disk access during a search :)


Jerry


[1]  Script for coding +keyPathsForValuesAffecting...

#!/bin/sh
echo + (NSSet*)keyPathsForValuesAffecting {
echo  return [NSSet setWithObjects:
echo  @\\,
echo  nil] ;
echo }
echo

___

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

Please do not post 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: File Reading Problems

2009-04-29 Thread Pierce Freeman
Hey Ken:

Your advice is really appreciated, and I will definitely look over the
Memory Management Guidelines when I have a bit more time in my day. ;)


On 4/29/09 1:12 PM, Ken Thomases k...@codeweavers.com wrote:

 On Apr 28, 2009, at 9:19 PM, Pierce Freeman wrote:
 
 - (void)awakeFromNib
 {
NSFileHandle *remoteConnection = [NSFileHandle
 fileHandleForReadingAtPath:@/Users/user/Desktop/file.plist];
 
 The above does not promise to keep the NSFileHandle object around for
 as long as you need it.  It's not at all clear to me that -
 readToEndOfFileInBackgroundAndNotify retains the file handle for its
 duration.
 
 So, you need to manage the lifetime of the file handle by retaining it
 here and releasing it when you know you're done with it.
 
 
[[NSNotificationCenter defaultCenter] addObserver:self
 selector:@selector(readAllTheData:)
 name:NSFileHandleReadToEndOfFileCompletionNotification
 object:remoteConnection];
[remoteConnection readToEndOfFileInBackgroundAndNotify];
 
 }
 
 - (void)readAllTheData:(NSNotification *)note {
NSString *errors = nil;
NSData *contentsOfDockFile = [note object];
NSLog(@%@, contentsOfDockFile);
NSDictionary *testing = [NSPropertyListSerialization
 propertyListFromData:contentsOfDockFile
 mutabilityOption:NSPropertyListImmutable format:nil
 errorDescription:errors];
NSLog(@%@, testing);
 
[[NSNotificationCenter defaultCenter] removeObserver:self
 name:NSFileHandleReadToEndOfFileCompletionNotification object:[note
 object]];
 
[testing release];
 }
 
 
 On Apr 28, 2009, at 10:15 PM, Pierce Freeman wrote:
 
 I added [testing retain] after the declaration of
 the variable, and I no longer get the wheel of death and my app
 freezing up.
 
 This smacks of flailing without understanding.
 
 The problem with your original code is that -propertyListFromData:...
 gives you an object, but does not give you the right/responsibility
 for releasing it, and yet you were releasing it anyway.
 
 While it is technically correct to solve this by adding [testing
 retain], it is redundant.  You could have just removed your [testing
 release].  The object is guaranteed to live at least until you return
 out of your -readAllTheData: method, so you need not retain it.  And,
 if you don't retain it, you should not release it.
 
 All this is to concur with Adam's suggestion that you reread the
 memory management guide.
 
 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: virtual keycode to character

2009-04-29 Thread kvic...@pobox.com

ken,
thank you. this solved my problem.

and for the archives (to help anyone in the future), here is my code:

UInt32 deadKeyState = 0;
UniCharCount actualCount = 0;
UniChar baseChar;
TISInputSourceRef sourceRef = TISCopyCurrentKeyboardLayoutInputSource();
CFDataRef keyLayoutPtr = (CFDataRef)TISGetInputSourceProperty( 
sourceRef, kTISPropertyUnicodeKeyLayoutData);

CFRelease( sourceRef);
UCKeyTranslate( (UCKeyboardLayout*)CFDataGetBytePtr(keyLayoutPtr),
[theEvent keyCode],
kUCKeyActionDown,
0,
LMGetKbdLast(),
kUCKeyTranslateNoDeadKeysBit,
deadKeyState,
1,
actualCount,
baseChar);

ken

p.s. i realize this might have a bug if the unicode for the 
unmodified keyboard character is more than 1 unicharacter.



At 9:53 PM -0500 4/27/09, Ken Thomases wrote:

On Apr 27, 2009, at 7:46 PM, kvic...@pobox.com wrote:

in my app, i allow the user to specify keyboard shortcuts for menu 
items (in a manner similar to xcode). for the string passed to 
-[MenuItem setKeyEquivalent], i pass the string obtained from the 
current event via [NSEvent charactersIgnoringModifiers]. this works 
fine almost all the time. however, for some keyboard presses it 
doesn't work properly, namely for shift and some of the number 
keys, eg., command-! (command exclamation mark) doesn't work as a 
keyboard equivalent, but shift-command-1 (shift command one) does 
work. thus, i would like a reliable way to go from virtual keycode 
to the non-shifted character.


in searching the archives, this topic has come up several times, 
but all proposed solutions that i've found make use of one or more 
deprecated (in leopard) api calls. eg., LMGetKBDType or 
GetScriptManagerVariable, etc.


does anyone have a solution that doesn't rely on any deprecated api calls?


You can use TISCopyCurrentKeyboardLayoutInputSource to get the 
current keyboard input source.  Then, you can query it using 
TISGetInputSourceProperty with kTISPropertyUnicodeKeyLayoutData to 
get the 'uchr' data for that keyboard layout.  With that, you can 
call UCKeyTranslate.


By the way, LMGetKbdType is not deprecated, at least according to 
its declaration in the headers.  It is documented on a page which 
is, as a whole, marked as a legacy document.  However, I don't know 
of a way to obtain the keyboard type otherwise (except in the 
context of a Carbon event).


Cheers,
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: virtual keycode to character

2009-04-29 Thread Ken Thomases

On Apr 29, 2009, at 6:40 PM, kvic...@pobox.com wrote:


thank you. this solved my problem.


You're welcome.  I'm glad I could help.



and for the archives (to help anyone in the future), here is my code:

UInt32 deadKeyState = 0;
UniCharCount actualCount = 0;
UniChar baseChar;
TISInputSourceRef sourceRef =  
TISCopyCurrentKeyboardLayoutInputSource();
CFDataRef keyLayoutPtr =  
(CFDataRef)TISGetInputSourceProperty( sourceRef,  
kTISPropertyUnicodeKeyLayoutData);

CFRelease( sourceRef);
UCKeyTranslate( (UCKeyboardLayout*)CFDataGetBytePtr(keyLayoutPtr),
  [theEvent keyCode],
 kUCKeyActionDown,
   0,
  LMGetKbdLast(),


Why LMGetKbdLast rather than LMGetKbdType?  I think that the Last in  
LMGetKbdLast means former.  That is, if the keyboard is switched at  
some point, then LMGetKbdType gives the current keyboard type and  
LMGetKbdLast gives the previous keyboard type.




kUCKeyTranslateNoDeadKeysBit,
   deadKeyState,
  1,
  actualCount,
   baseChar);


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


Changing CoreData store type

2009-04-29 Thread Jim Thomason
Howdy all,

Hopefully this is a ridiculously simple question with a ridiculously
simple answer, but I just haven't been able to find it.

I have a document based CoreData app and I want to change the store
type of the file. So it previously saved as XML, and I now want those
docs to save as SQLite. But, i still want to be able to view the XML
based docs, just require the user to re-save as SQLite. There are no
changes to the model. All the data looks and is structured the same.

So I added a new document type with a SQLite store and a different
doctype and set it to editor. I left the old doc available as an
editable document.

At this point, I can open up an XML document, edit it, save it, and
then re-save it as a SQLite document w/o any issues.

The problem is when I flip the XML doc from Editor - Viewer. I can no
longer save it in place (as expected), but whenever I try to save it
as the SQLite doc, the app crashes. I know that it's bombing somewhere
inside NSPersistentDocument's
writeToURL:ofType:forSaveOperation:originalContentsURL:error:, but
beyond that am lost. In the save document window, the doc type is
correctly set to the new extension for the SQLite store.

Again, when the app is set to editor for XML, I can re-save the doc as
SQLite. When I can only view the XML docs, re-saving as SQLite
crashes.

I've tried all sorts of incantations with PersistentStoreCoordinator's
migratePersistentStore:toURL:options:withType:error:,
addPersistentStoreForURL:, removePersistentStore:error: and have
gotten nowhere. I've also tried explicitly setting the document's
fileType, but have had no luck.

Clearly, this is something that should be easy, since the app handles
it automatically when I can edit the XML docs.

So what do I need to do?

Many thanks in advance,

-Jim
___

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

Please do not post 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


Scheduling a selector when a thread completes

2009-04-29 Thread kentozier
Hi 


I wrote a directory scanner application that spawns 4 different threads with 
independent rescan intervals and need to repeat the process if and only if a 
thread has completed a scan. Basically, for each file type I'm watching, the 
process is 


1. Spawn a thread to sample files of the specified type 
2. Wait until the thread completes 
3. Schedule another pass after a given time interval has passed. 


Timer's don't work for my purposes because the execution time of the thread can 
easily exceed any arbitrary repeat interval I might choose which would require 
the use of busy flags and testing for a busy state etc... I want to avoid that. 


I tried calling NSObject's 


performSelector:(SEL) aSelector   withObject:(id) anArgument   afterDelay:( 
NSTimeInterval ) delay 



But the receiver's  aSelector  method is never getting called. The only 
logical place to perform this scheduling is from inside the thread because only 
the thread knows when it is finished, but I'm having no luck getting the method 
to run. 


Here are the methods that spawn the threads 




- ( void ) initDirectories 

{ 

     [ NSThread detachNewThreadSelector : @selector ( initDirectoriesInThread 
:) 

          toTarget : self 

          withObject : nil ]; 

} 




- ( void ) updateDirectories 

{ 

     // Logging function that writes messages to my app's custom console view 


    KCLog ([ NSString stringWithFormat : @Checking for changes: %@ , 
userType]); 




    [ NSThread detachNewThreadSelector : @selector ( updateDirectoriesInThread 
:) 

        toTarget : self 

        withObject : nil ]; 

} 




And here are the corresponding thread methods 






- ( void ) initDirectoriesInThread:( id ) inData 

{ 

     @synchronized ( self ) 

     { 

        // allocate a new autorelease pool 

        NSAutoreleasePool *pool = [[ NSAutoreleasePool alloc ] init ]; 




        KDirectory *rootDirectory = [ KDirectory directoryWithPath : path ]; 

        rootObserver = [[ CNCDirectoryWatcher alloc ] initWithDirectory : 
rootDirectory root : self ]; 




        // add root directory to observed list 

        [ self addDirectory : rootObserver ]; 




        // schedule a new pass 

        [ self performSelector : @selector ( updateDirectories ) withObject : 
nil afterDelay : catalogInterval ]; 




        // release the pool 

        [pool release ]; 

    } 

} 




- ( void ) updateDirectoriesInThread:( id ) inData 

{ 

    @synchronized ( self ) 

    { 

        // allocate a new autorelease pool 

        NSAutoreleasePool *pool = [[ NSAutoreleasePool alloc ] init ]; 

         NSArray *dirs = [ directories copy ]; 


        NSEnumerator *enumerator = [dirs objectEnumerator ]; 

         CNCDirectoryWatcher *directory; 





        while (directory = [enumerator nextObject ]) 

        { 

            [directory update ]; 

        } 




        // schedule a new pass 

        [ self performSelector : @selector ( updateDirectories ) withObject : 
nil afterDelay : catalogInterval ]; 




        // release the pool 

        [pool release ]; 

    } 

} 


The initDirectoriesInThread method is getting called and runs correctly, but 
the updateDirectoriesInThread method never gets called. 


I looked at  


-(void)performSelectorOnMainThread:(SEL) aSelector   withObject:(id) arg   
waitUntilDone:(BOOL) wait 



But it doesn't appear to have a way to schedule the execution for a specified 
delay. 


Is there a way to use  performSelector: withObject: afterDelay: to satisfy both 
step 2 and 3 above? 


Thanks for any help 

___

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

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

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

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


Re: Scheduling a selector when a thread completes

2009-04-29 Thread Marc Van Olmen
* You could use NSOperationQueue and set the maximumThread count to 1.  
and make for each of these methods an NSOperation. And then add those  
4 operations to your OperationQueue.


* But your case is simple so you can easily code this your self by  
creating an object for each operation you are performing. and create  
an Operation Array


yourself.

cheers,

marc



On Apr 29, 2009, at 9:55 PM, kentoz...@comcast.net wrote:


Hi


I wrote a directory scanner application that spawns 4 different  
threads with independent rescan intervals and need to repeat the  
process if and only if a thread has completed a scan. Basically, for  
each file type I'm watching, the process is



1. Spawn a thread to sample files of the specified type
2. Wait until the thread completes
3. Schedule another pass after a given time interval has passed.


Timer's don't work for my purposes because the execution time of the  
thread can easily exceed any arbitrary repeat interval I might  
choose which would require the use of busy flags and testing for a  
busy state etc... I want to avoid that.



I tried calling NSObject's


performSelector:(SEL) aSelector   withObject:(id) anArgument
afterDelay:( NSTimeInterval ) delay




But the receiver's  aSelector  method is never getting called. The  
only logical place to perform this scheduling is from inside the  
thread because only the thread knows when it is finished, but I'm  
having no luck getting the method to run.



Here are the methods that spawn the threads




- ( void ) initDirectories

{

 [ NSThread detachNewThreadSelector : @selector  
( initDirectoriesInThread :)


  toTarget : self

  withObject : nil ];

}




- ( void ) updateDirectories

{

 // Logging function that writes messages to my app's custom  
console view



KCLog ([ NSString stringWithFormat : @Checking for changes:  
%@ , userType]);





[ NSThread detachNewThreadSelector : @selector  
( updateDirectoriesInThread :)


toTarget : self

withObject : nil ];

}




And here are the corresponding thread methods






- ( void ) initDirectoriesInThread:( id ) inData

{

 @synchronized ( self )

 {

// allocate a new autorelease pool

NSAutoreleasePool *pool = [[ NSAutoreleasePool alloc ] init ];




KDirectory *rootDirectory = [ KDirectory directoryWithPath :  
path ];


rootObserver = [[ CNCDirectoryWatcher alloc ]  
initWithDirectory : rootDirectory root : self ];





// add root directory to observed list

[ self addDirectory : rootObserver ];




// schedule a new pass

[ self performSelector : @selector ( updateDirectories )  
withObject : nil afterDelay : catalogInterval ];





// release the pool

[pool release ];

}

}




- ( void ) updateDirectoriesInThread:( id ) inData

{

@synchronized ( self )

{

// allocate a new autorelease pool

NSAutoreleasePool *pool = [[ NSAutoreleasePool alloc ] init ];

 NSArray *dirs = [ directories copy ];


NSEnumerator *enumerator = [dirs objectEnumerator ];

 CNCDirectoryWatcher *directory;





while (directory = [enumerator nextObject ])

{

[directory update ];

}




// schedule a new pass

[ self performSelector : @selector ( updateDirectories )  
withObject : nil afterDelay : catalogInterval ];





// release the pool

[pool release ];

}

}


The initDirectoriesInThread method is getting called and runs  
correctly, but the updateDirectoriesInThread method never gets  
called.



I looked at


-(void)performSelectorOnMainThread:(SEL) aSelector   withObject:(id)  
arg   waitUntilDone:(BOOL) wait




But it doesn't appear to have a way to schedule the execution for a  
specified delay.



Is there a way to use  performSelector: withObject: afterDelay: to  
satisfy both step 2 and 3 above?



Thanks for any help

___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/mvo%40sky4studios.be

This email sent to m...@sky4studios.be


___

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

Please do not post 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: Scheduling a selector when a thread completes

2009-04-29 Thread Stephen J. Butler
On Wed, Apr 29, 2009 at 8:55 PM,  kentoz...@comcast.net wrote:
 I tried calling NSObject's


 performSelector:(SEL) aSelector   withObject:(id) anArgument   afterDelay:( 
 NSTimeInterval ) delay



 But the receiver's  aSelector  method is never getting called. The only 
 logical place to perform this scheduling is from inside the thread because 
 only the thread knows when it is finished, but I'm having no luck getting the 
 method to run.

You need to run the runloop in the thread in order for timers or the
performSelector* methods to work. Which changes your logic around a
lot.

One alternate way to get your goal is call
performSelectorOnMainThread:withObject:waitUntilDone: and pass it a
method that calls [self performSelector:@selector(updateDirectories)
withObject:self afterDelay:1.0] (or whatever delay you want).
___

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

Please do not post 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: Why is NSString-FSRef so hard?

2009-04-29 Thread Andrew Farmer

On 29 Apr 09, at 06:15, Mark Douma wrote:
If you are working with file paths, you shouldn't be using  
componentsSeparatedByString:, nor should you be defining / to be  
the component you should be separating by. What if someone had your  
app inside of a folder they named Apps/Utilities? The HFS+  
filesystem actually uses a colon as the path separator, so having  
a / in the name of a file or folder is perfectly acceptable, but  
would likely cause a headache and unexpected results if your code  
were to encounter it. (Go to the Finder and try adding a /).


What you're saying here is incredibly misleading, and actively  
harmful. While I believe that HFS+ uses : as a path separator on- 
disk, virtually all non-Carbon userspace code makes use of UNIX paths.  
Either Carbon or the Finder itself is swapping colons and slashes for  
display purposes - running ls should reveal that filenames which  
appear as slashes in the Finder appear as colons.


Indeed, the methods in NSPathUtilities are entirely equivalent to  
string manipulation methods which split and join on slashes. They  
handle a lot of special cases for you (absolute paths, for instance),  
but they are in no way doing anything specific to HFS+. Moreover, you  
can rely on the path separator remaining a slash for the foreseeable  
future.

___

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

Please do not post 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: Scheduling a selector when a thread completes

2009-04-29 Thread Greg Guerin

2. Wait until the thread completes



NSThreadWillExitNotification?

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


Building a 64-bit Preferences Pane

2009-04-29 Thread 慧 松本
I have been trying to make a simple 64-bit preference pane. But all  
trials ended in failure.


For example:
1) Make a new preference pane project SamplePrefPane with Xcode.
2) Set the build option ARCHS to x86_64
3) Build it and double click SamplePrefPane.prefPane

Then System Preferences app says:
 Preferences Error
 You can't open SimplePrefPane preferences because
 it doesn't work on an Intel-based Mac.

But my machine is MacPro, Quad-Core Intel Xeon.

When I change the build option ARCHS to 32-bit universal, it works  
fine.


Does anybody know how to make 64-bit preference panes?

Satoshi
-
Satoshi Matsumoto sato...@mac.com
816-5 Odake, Odawara, Kanagawa, Japan 256-0802




___

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

Please do not post 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: Building a 64-bit Preferences Pane

2009-04-29 Thread Kiel Gillard

Hi Satoshi,

If you run this in Terminal:
Bugdom:~ kiel$ file /Applications/System\ Preferences.app/Contents/ 
MacOS/System\ Preferences
/Applications/System Preferences.app/Contents/MacOS/System  
Preferences: Mach-O universal binary with 2 architectures
/Applications/System Preferences.app/Contents/MacOS/System Preferences  
(for architecture i386):	Mach-O executable i386
/Applications/System Preferences.app/Contents/MacOS/System Preferences  
(for architecture ppc7400):	Mach-O executable ppc


You can see the System Preferences application is not a 64 bit  
application (at least, not yet). Therefore, you cannot make a 64 bit  
preference pane.


Kiel

On 30/04/2009, at 12:48 PM, 慧 松本 wrote:

I have been trying to make a simple 64-bit preference pane. But all  
trials ended in failure.


For example:
1) Make a new preference pane project SamplePrefPane with Xcode.
2) Set the build option ARCHS to x86_64
3) Build it and double click SamplePrefPane.prefPane

Then System Preferences app says:
Preferences Error
You can't open SimplePrefPane preferences because
it doesn't work on an Intel-based Mac.

But my machine is MacPro, Quad-Core Intel Xeon.

When I change the build option ARCHS to 32-bit universal, it  
works fine.


Does anybody know how to make 64-bit preference panes?

Satoshi
-
Satoshi Matsumoto sato...@mac.com
816-5 Odake, Odawara, Kanagawa, Japan 256-0802




___

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

Please do not post 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/kiel.gillard%40gmail.com

This email sent to kiel.gill...@gmail.com


___

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

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

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

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


Re: Building a 64-bit Preferences Pane

2009-04-29 Thread Andrew Farmer

On 29 Apr 09, at 19:48, 慧 松本 wrote:

Does anybody know how to make 64-bit preference panes?


You can't, yet. The System Preferences application - which loads  
preference panes as plugins - is still 32-bit only, so it can't load  
64-bit prefpane plugins.


Rumor has it this may change in 
10.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/archive%40mail-archive.com

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


Re: Scheduling a selector when a thread completes

2009-04-29 Thread Michael Ash
On Wed, Apr 29, 2009 at 9:55 PM,  kentoz...@comcast.net wrote:
 Hi


 I wrote a directory scanner application that spawns 4 different threads with 
 independent rescan intervals and need to repeat the process if and only if a 
 thread has completed a scan. Basically, for each file type I'm watching, the 
 process is


 1. Spawn a thread to sample files of the specified type
 2. Wait until the thread completes
 3. Schedule another pass after a given time interval has passed.

Seems like you're adding a lot of complication for what is essentially
a continually running operation. Instead of that, why not do this?

1. Spawn a thread.
2. Sample files.
3. Sleep.
4. Goto 2.

Or, in code:

- (void)threadMethod {
while(1) {
[self sampleFiles];
sleep(5);
}
}

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: Why is NSString-FSRef so hard?

2009-04-29 Thread Michael Ash
On Wed, Apr 29, 2009 at 10:22 PM, Andrew Farmer andf...@gmail.com wrote:
 On 29 Apr 09, at 06:15, Mark Douma wrote:

 If you are working with file paths, you shouldn't be using
 componentsSeparatedByString:, nor should you be defining / to be the
 component you should be separating by. What if someone had your app inside
 of a folder they named Apps/Utilities? The HFS+ filesystem actually uses a
 colon as the path separator, so having a / in the name of a file or folder
 is perfectly acceptable, but would likely cause a headache and unexpected
 results if your code were to encounter it. (Go to the Finder and try adding
 a /).

 What you're saying here is incredibly misleading, and actively harmful.
 While I believe that HFS+ uses : as a path separator on-disk, virtually
 all non-Carbon userspace code makes use of UNIX paths. Either Carbon or the
 Finder itself is swapping colons and slashes for display purposes - running
 ls should reveal that filenames which appear as slashes in the Finder
 appear as colons.

It is a baffling myth, and I can't understand how anyone with any
experience with the system would actually believe it. The OS goes
through a great deal of trouble to make HFS+ filesystems look and
behave exactly like any other UNIX-visible filesystem. Do you not use
Terminal? Do you not examine any of the hundreds or thousands of paths
flying through your application? They *all* use / as the path
separator.

(The reason a folder named Apps/Utilities does not break things is
because at the UNIX level this is represented as Apps:Utilities. / is
not allowed in filenames at that level, period. Doesn't matter what
filesystem you're on.)

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: Building a 64-bit Preferences Pane

2009-04-29 Thread 慧 松本


On 2009/04/30, at 12:05, Andrew Farmer wrote:

On 29 Apr 09, at 19:48, 慧 松本 wrote:

Does anybody know how to make 64-bit preference panes?


You can't, yet. The System Preferences application - which loads  
preference panes as plugins - is still 32-bit only, so it can't load  
64-bit prefpane plugins.


Sorry, I forgot to mention my OS environment. I am developing the  
preference pane on Mac OS X 10.6 Snow Leopard build 10A335.

Does my question violate NDA?

Satoshi
-
Satoshi Matsumoto sato...@mac.com
816-5 Odake, Odawara, Kanagawa, Japan 256-0802




___

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

Please do not post 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: Building a 64-bit Preferences Pane

2009-04-29 Thread Clark Cox
2009/4/29 慧 松本 sato...@mac.com:

 On 2009/04/30, at 12:05, Andrew Farmer wrote:

 On 29 Apr 09, at 19:48, 慧 松本 wrote:

 Does anybody know how to make 64-bit preference panes?

 You can't, yet. The System Preferences application - which loads
 preference panes as plugins - is still 32-bit only, so it can't load 64-bit
 prefpane plugins.

 Sorry, I forgot to mention my OS environment. I am developing the preference
 pane on Mac OS X 10.6 Snow Leopard build 10A335.
 Does my question violate NDA?

Take it to https://devforums.apple.com/community/mac

-- 
Clark S. Cox III
clarkc...@gmail.com
___

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

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

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

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


Re: Why is NSString-FSRef so hard?

2009-04-29 Thread Charles Srstka

On Apr 29, 2009, at 9:22 PM, Andrew Farmer wrote:


On 29 Apr 09, at 06:15, Mark Douma wrote:
If you are working with file paths, you shouldn't be using  
componentsSeparatedByString:, nor should you be defining / to be  
the component you should be separating by. What if someone had your  
app inside of a folder they named Apps/Utilities? The HFS+  
filesystem actually uses a colon as the path separator, so having  
a / in the name of a file or folder is perfectly acceptable, but  
would likely cause a headache and unexpected results if your code  
were to encounter it. (Go to the Finder and try adding a /).


What you're saying here is incredibly misleading, and actively  
harmful. While I believe that HFS+ uses : as a path separator on- 
disk, virtually all non-Carbon userspace code makes use of UNIX  
paths. Either Carbon or the Finder itself is swapping colons and  
slashes for display purposes - running ls should reveal that  
filenames which appear as slashes in the Finder appear as colons.


Indeed, the methods in NSPathUtilities are entirely equivalent to  
string manipulation methods which split and join on slashes. They  
handle a lot of special cases for you (absolute paths, for  
instance), but they are in no way doing anything specific to HFS+.  
Moreover, you can rely on the path separator remaining a slash for  
the foreseeable future.


Carbon and the Finder are displaying the filenames as is, as HFS  
allows slashes to be in a filename, and the colon is the separator.  
Cocoa and the BSD layer, on the other hand, do swap the slashes and  
colons. Presumably the idea is to display slashes in a filename as  
whatever the path separator is supposed to be, so that the path can be  
a standard UNIX path - my guess is that if you had a file on an NTFS  
volume with a slash in its filename, Cocoa would interpret the slash  
as a backslash. I don't have an NTFS disk to test that with, though.


With that said, I don't really see what is harmful about recommending  
the use of NSString's path concatenation methods, which could save  
quite a few headaches in the case that this *does* somehow change for  
some bizarre reason, however unlikely that may be.


Charles
___

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

Please do not post 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: Drawing Across NSTableView Columns [solved]

2009-04-29 Thread K. Darcy Otto
Thank you for the suggestions.  It turns out that I went the second  
way, and it works just fine (to tell you the truth, I was a bit  
apprehensive at getting into drawing, but it wasn't as difficult as I  
had suspected - the -frameOfCellAtColumn:row: really made everything  
not too bad at all).  Here is my code, added to the NSTableView  
subclass, just in case someone else runs into this issue.  slp is  
just an NSArray of  3 integers which represent the beginning row, the  
ending row, and the depth (how far indented) each of the lines should  
be.  If a line isn't meant to have an end, end=0, and then the line is  
drawn in blue as opposed to steel.


-(void)drawRect:(NSRect)rect
{
// Draw the table first, by calling drawRect from the superclass
[super drawRect:rect];

// Do nothing if no slp's
NSArray *slp = [mydoc slp];
NSUInteger slpCount = [slp count];
if (slpCount == 0) return;

	NSColor *blueish = [NSColor colorWithDeviceRed:0.0 green:.5 blue:1.0  
alpha:.75]; // Some sort of blue
	NSColor *steelish = [NSColor colorWithDeviceRed:.5797 green:.5797  
blue:.5797 alpha:.75]; // Some sort of steel

BOOL endToLine;

for (NSUInteger i=0; islpCount; i++)
{
NSBezierPath *thePath = [NSBezierPath bezierPath];
[thePath setLineWidth:2.0];

// Find starting point for line
NSUInteger beginAtRow = [[slp objectAtIndex:i] begin];
NSUInteger endAtRow = [[slp objectAtIndex:i] end];
NSUInteger depth = [[slp objectAtIndex:i] depth];

// If endAtRow is zero, run the line to the bottom of the table
if (endAtRow == 0)
{
endAtRow = [datasource rowCount]-1;
// Set pen colour to blueish
[blueish set];
// Flag no end to line
endToLine = NO;
}
else
{
// Set pen colour to steelish
[steelish set];
// Flag endToLine
endToLine = YES;
}

		NSRect beginAtRowRect = [self frameOfCellAtColumn:[self  
columnWithIdentifier:@F] row:beginAtRow];
		NSRect endAtRowRect = [self frameOfCellAtColumn:[self  
columnWithIdentifier:@F] row:endAtRow];


NSPoint beginPoint, endPoint;
		beginPoint.y = beginAtRowRect.origin.y + beginAtRowRect.size.height/ 
2.0;

beginPoint.x = beginAtRowRect.origin.x + depth*7.0;
endPoint.y = endAtRowRect.origin.y + 
endAtRowRect.size.height/2.0;
endPoint.x = endAtRowRect.origin.x + depth*7.0;

[thePath setLineCapStyle:NSSquareLineCapStyle];
[thePath setLineJoinStyle:NSRoundLineJoinStyle];

// Move to starting location, and draw the line
[thePath moveToPoint:(NSMakePoint(beginPoint.x+5, 
beginPoint.y))];
[thePath lineToPoint:beginPoint];
[thePath lineToPoint:endPoint];
		if (endToLine) [thePath lineToPoint:(NSMakePoint(endPoint.x+5,  
endPoint.y))];

[thePath stroke];
}
}

___

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

Please do not post 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: Changing a custom field editor's position

2009-04-29 Thread K. Darcy Otto

Hi Ulai,

Did you find a solution to this problem?  I'm trying to do the same  
thing.


Darcy


Hi,

Let's say I want to have the field editor for a table view appear 2  
pixel below where it usually is, i.e. shifted 2 pixels down.

How can I do this?

Consider the following hypothetical situation: If I subclass  
NSTextView and override the drawRect method like this,


- (void)drawRect:(NSRect)rect
{
  NSRect frame = [self frame];
  frame.origin.x += 5.0;
  [self setFrame:frame];

  [super drawRect:rect];
}

and use this subclass for the field editor of my table view, no  
changes occur. But shouldn't this custom field editor move by 5.0  
pixels to the right on and on until it finally disappears and  
becomes invisible? But for some reasons that does not happen. This  
means that setting the frame's origin apparently has no effect.


And that is essentially why I'm all blank on how to reposition the  
field editor. Any ideas?


Thanks, U

___

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

Please do not post 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: Why is NSString-FSRef so hard?

2009-04-29 Thread Jim Correia
On Thu, Apr 30, 2009 at 12:02 AM, Charles Srstka
cocoa...@charlessoft.com wrote:
 With that said, I don't really see what is harmful about recommending the
 use of NSString's path concatenation methods, which could save quite a few
 headaches in the case that this *does* somehow change for some bizarre
 reason, however unlikely that may be.

Even if the path separator never changes, they are still beneficial to
use because they automatically handle both the trailing slash present
and trailing slash missing cases transparently

[@/foo stringByAppendingPathComponent: @bar] - /foo/bar
[@/foo/ stringByAppendingPathComponent: @bar] - /foo/bar

- Jim
___

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

Please do not post 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: Why is NSString-FSRef so hard?

2009-04-29 Thread Michael Ash
On Thu, Apr 30, 2009 at 12:02 AM, Charles Srstka
cocoa...@charlessoft.com wrote:
 With that said, I don't really see what is harmful about recommending the
 use of NSString's path concatenation methods, which could save quite a few
 headaches in the case that this *does* somehow change for some bizarre
 reason, however unlikely that may be.

Nothing wrong with recommending the NSString methods. Indeed, that's a
good idea. What's harmful is spreading false information about HFS's
path separators. When dealing with UNIX paths, the OS X path separator
is /, end of story. (When dealing with Carbon paths, it's :, no matter
what your filesystem, even on UFS, even on FAT32, but a Cocoa app
rarely has any occasion to use Carbon paths.)

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: Repositioning the Field Editor

2009-04-29 Thread K. Darcy Otto
So, I have continued my work with a subclass of NSTextView for my  
field editor, and here is another part of the puzzle: (i) if I  
implement -drawRect: in the subclass, and ask it for the frame, the  
frame is the same as the frame set in -viewWillDraw, but not acted  
upon; (ii) if I implement -drawRect: in the subclass, but do not call  
super, the field editor box is still drawn at the usual location (the  
text is not drawn properly, etc., but the box is).  This leads me to  
think that -drawRect is not drawing the box for the field editor.  The  
question is, what object is drawing that box, and is there a way to  
move it?


On 28-Apr-09, at 12:47 PM, K. Darcy Otto wrote:
Continuing on with the mystery, I have tried the following code in  
my NSTableView subclass (below, not yet solved though).  I have got  
it so that the rect returned by [fieldEditor frame] is not empty,  
but gives exactly the frame it should.  Still though, modifying the  
frame to something different makes no difference.  Is there a way to  
prompt the field editor to redraw itself in accordance with the new  
frame?


In the documentation for -editColumn:row:withEvent:select:, I  
noticed that it sends - 
selectWithFrame:inView:editor:delegate:start:length: and - 
editWithFrame:inView:editor:delegate:event: to the field editor’s  
NSCell object with the NSTableView as the text delegate.  So my call  
to super is doing that.  Could it be that I need to intervene  
somehow in these NSCell methods?


-(void)editColumn:(NSInteger)columnIndex row:(NSInteger)rowIndex  
withEvent:(NSEvent *)theEvent select:(BOOL)flag

{
	[super editColumn:columnIndex row:rowIndex withEvent:theEvent  
select:flag];
	NSTextView *fieldEditor = (NSTextView *)[[self window]  
fieldEditor:YES forObject:nil];


	// Change the text colour to red, just to confirm I've got ahold of  
the actual field editor that is being used (I do)

[fieldEditor setTextColor:[NSColor redColor]];

// Get the field editor frame (it is the correct frame)
NSRect cellRect = [fieldEditor frame];
	NSLog(@1. fieldEditor x origin: %f,cellRect.origin.x); // output:  
127


// Change cellRect x origin, but don't extend the field width
cellRect.origin.x += 20;
cellRect.size.width -= 20;

// Set fieldEditor frame to new cellRect
[fieldEditor setFrame:cellRect];
[fieldEditor setNeedsDisplay:YES];

cellRect = [fieldEditor frame];
	NSLog(@2. fieldEditor x origin: %f,cellRect.origin.x); // output:  
147

}

On 27-Apr-09, at 7:19 PM, K. Darcy Otto wrote:

I have a field editor which I need to reposition in my tableView –  
specifically, I need to move it a few pixels to the right.  The  
following post:


http://www.cocoabuilder.com/archive/message/cocoa/2009/3/16/232513

makes two suggestions: (i) implement the move in -viewWillDraw in  
the field editor subclass, and (ii) reposition the field editor  
after calling super in -editColumn:row:withEvent:select: in the  
tableView subclass.  Neither of these seem to make any difference  
to where the field editor is drawn.  Here is my code with respect  
to (i), contained in the field editor subclass:


-(void)viewWillDraw
{
NSRect frame = [self frame];
NSLog(@Old: %f,frame.origin.x);
frame.origin.x += 50.0;
[self setFrame:frame];
frame = [self frame];
NSLog(@New: %f,frame.origin.x);

[super viewWillDraw];
}

Now, I can confirm this method is being called, and by means of the  
NSLog statements, the frame is being changed prior to the call to  
super.  Unfortunately, the field editor is drawn where is usually  
is drawn, with no shift in place.


With respect to (ii), contained in the tableView subclass:

-(void)editColumn:(NSInteger)columnIndex row:(NSInteger)rowIndex  
withEvent:(NSEvent *)theEvent select:(BOOL)flag

{
	[super editColumn:columnIndex row:rowIndex withEvent:theEvent  
select:flag];
	NSText *fieldEditor = [[self window] fieldEditor:YES  
forObject:self];

NSRect fieldEditorFrame = [fieldEditor frame];
fieldEditorFrame.origin.x += 50.0;
[fieldEditor setFrame:fieldEditorFrame];
}

Here, it turns out that even though fieldEditor points to the  
custom field editor object, fieldEditorFrame turns out to be  
empty.  And again, the field editor is drawn where it is usually  
drawn, with no shift in place.


Any help would be greatly appreciated.



___

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

Please do not post 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/dotto%40csusb.edu

This email sent to do...@csusb.edu


___

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

Please do not post admin requests 

Animating .gif in NSImageView

2009-04-29 Thread led248
In Interface Builder, I dragged an Image Well (NSImageView) onto my  
window and checked the Animates and Editable attribute flags.


When running my app, I can drag a .gif into the Image Well and it  
works great -- the animated gif animates.


If I cut and paste back into the same Image Well, the image appears  
but there is no animation.


Same thing happens when I archive/unarchive -- the first frame  
appears, but no animation.


So drop works, paste and unarchive don't.  Which has me a bit  
baffled.  Clearly, NSImageView has the ability to display animated gif  
files, because it is doing so for my dropped files.  But not for files  
loaded by other means.


Is there some method I need to invoke after pasting or unarchiving  
that will cause the gif animation to start?


Would really appreciate any ideas or solutions!

___

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

Please do not post 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


NSURLConnection unhappiness

2009-04-29 Thread Nick Hristov
Hello,

I am currently working on a small iphone app, and I am facing some
difficulty with getting NSURLConnection to ... connect. Basically my unit
tests don't pass: connection is never made.

Here is a snippet of the non-working code:

code

- (id) initWithURL: (NSURL*) someurl
{
self = [super init];
if (self != nil) {
self-url = [someurl copy];
NSURLRequest * request = [NSURLRequest requestWithURL:self-url
cachePolicy: NSURLRequestUseProtocolCachePolicy timeoutInterval: 6.0];
NSLog([NSString stringByAppendingStrings:@Request:  , [request
description], nil]);
self-finished = NO;
self-connection = [[NSURLConnection alloc]
initWithRequest:requestdelegate:self startImmediately:NO];
}
return self;
}

- (void) downloadData
{
NSLog([self-connection description]);
NSLog(@run, b*$#4rd, run...);
[self-connection scheduleInRunLoop:[NSRunLoop currentRunLoop]
forMode:NSDefaultRunLoopMode];
[self-connection start];
int timeout = 30;
int i = 0;
while(self-finished == NO  [self _deletegateTerminateCheck] == NO) {
// suspend thread
[NSThread sleepForTimeInterval: 1.0];
i++;

/// stupid, but effective safety measure:
if(i = timeout) {
break;
}
}
}

- (NSData *) data {
return self-data;
}

#pragma mark NSConnectionDelegate implementation
- (NSURLRequest *)connection:(NSURLConnection *)connection
willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse
*)response
{
NSLog(@Will send request);
return request;
}


- (void)connection:(NSURLConnection *)connection
didReceiveResponse:(NSURLResponse *)response
{
NSLog(@Did get response);
NSString * encoding = [response textEncodingName];
self-dataEncoding = [self getEncodingForEncodingName: encoding];
self-mimeType = [response MIMEType];
}

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData
*)receiveddata
{
NSLog(@Did get data);
if([self _deletegateTerminateCheck]) {
if(self-data != nil) {
[self-data release];
self-data = nil;
}
[self-connection cancel];
[self-connection release];
self-connection = nil;
return;
}
if(self-data == nil) {
self-data = [[NSMutableData alloc]init];
}
[self-data appendData:receiveddata];
}

- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
NSLog(@did finish loading page);
self-finished = YES;
}


- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError
*)error
{
NSLog([NSString stringByAppendingStrings:@Connection failed with error:
 , [error description], nil]);
self-finished = YES;
}

- (NSCachedURLResponse *)connection:(NSURLConnection *)connection
willCacheResponse:(NSCachedURLResponse *)cachedResponse
{
NSLog(@Will cache response);
return cachedResponse;
}

- (void) dealloc {
if(self-url !=nil) {
[self-url release];
self-url = nil;
}
if(self-connection != nil) {
[self-connection release];
self-connection = nil;
}
[super dealloc];
}
/code

Here is the output that I get from the build:

2009-04-25 14:14:22.699 otest[6135:80f] Request: NSURLRequest
http://arstechnica.com
2009-04-25 14:14:22.704 otest[6135:80f] NSURLConnection: 0x31d2a0,
http://arstechnica.com
2009-04-25 14:14:22.705 otest[6135:80f] run, b*$#4rd, run...
2009-04-25 14:14:22.706 otest[6135:80f] hello?
2009-04-25 14:14:52.709 otest[6135:80f] Data is nil!

Data is nil! is dumped by the

[NSString stringByAppendingStrings:  ] is my own extension and it works.

I also found
http://www.cocoabuilder.com/archive/message/cocoa/2009/3/31/233409 which
helped, without scheduling in the run loop things fail miserably.

Once again, this is all run inside a unit test. So I am not sure what else
may be missing from the run loop, looks like the URL connection never really
even starts the loading mechanism.

Thanks a bunch,

Nick
___

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

Please do not post 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: NSURLConnection unhappiness

2009-04-29 Thread Jeff Johnson

Hi Nick.

You can't sleep the thread. According to the documentation for - 
[NSThread sleepForTimeInterval:], No run loop processing occurs while  
the thread is blocked.. You need to run the run loop for the  
connection to process.


On an unrelated note, your use of self-connection, etc., is non- 
standard and not advised. You should be using direct ivar access  
connection, properties self.connection, or accessor methods [self  
connection].


-Jeff


On Apr 29, 2009, at 11:31 PM, Nick Hristov wrote:


- (void) downloadData
{
   NSLog([self-connection description]);
   NSLog(@run, b*$#4rd, run...);
   [self-connection scheduleInRunLoop:[NSRunLoop currentRunLoop]
forMode:NSDefaultRunLoopMode];
   [self-connection start];
   int timeout = 30;
   int i = 0;
   while(self-finished == NO  [self _deletegateTerminateCheck] ==  
NO) {

   // suspend thread
   [NSThread sleepForTimeInterval: 1.0];
   i++;

   /// stupid, but effective safety measure:
   if(i = timeout) {
   break;
   }
   }
}


___

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

Please do not post 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


Registering Clients using DO

2009-04-29 Thread Kiran Kumar S
I am developing a client/server application using DO. In server an  
object is vended to be accessible by clients.In the client side i am  
accessing vended object and get required info from server.Every thing  
works fine. Until now my client queries server and server replies to  
that. But on serverside if any updates goes, i had to inform client.so  
i thought of registering the client and ping the client for updates.So  
in Client side i get vended object and registered it to server.When my  
server pings the client its  giving error *** NSDistantObject  
initWithCoder: 0x1 not given away for conn 0xf8937f0
I think my registering of client with server goes wrong , can anyone  
suggest me what i am missing here.If any sample code that would be  
great.

Server
---
main() {
int newSocket = socket(AF_INET, SOCK_STREAM, 0);
struct sockaddr_in address;
memset(address, 0, sizeof(address));
address.sin_family = AF_INET;
address.sin_addr.s_addr = htonl(INADDR_ANY);
address.sin_port = htons(PORT_NUMBER);int yes = 1;
setsockopt(newSocket, SOL_SOCKET, SO_REUSEADDR, yes, sizeof(yes));
bind(newSocket, (struct sockaddr *)address, sizeof(address));
listen(newSocket, 128);
	NSSocketPort *serverPort = [[NSSocketPort alloc]  
initWithProtocolFamily:PF_INET socketType:SOCK_STREAM protocol:0  
socket:newSocket];
	connection = [[NSConnection alloc] initWithReceivePort:serverPort  
sendPort:serverPort];

NSRunLoop *runloop = [NSRunLoop currentRunLoop];
[connection setRootObject:[ServerObject sharedServerObject]];
[connection addRunLoop:runloop];
[runloop run];
}
@implementation ServerObject : NSObject
-(void)registerClient:(idNetClientProto)client {
[clients setObject:client forKey: @C1];
if(![timer isValid])
	  timer = [[NSTimer scheduledTimerWithTimeInterval:1 target:self  
selector:@selector(pingClients) userInfo:nil repeats:YES] retain];

}
-(void)pingClients {
[[clients objectForKey:[[clients allKeys] lastObject]] ping];
}

Client
---
-(id)getServer{
 @try{  
	NSSocketPort  *port = [[NSSocketPort alloc]  
initRemoteWithTCPPort:PORT_NUMBER host:host];
	NSConnection *connection = [[NSConnection  alloc]  
initWithReceivePort:nil sendPort:port];

[connection setDelegate:self];
	[[NSNotificationCenter defaultCenter] addObserver:self  
selector:@selector(handleConnectionDied:)  
name:NSConnectionDidDieNotification object:serverConnection];

[port release];
serverObject = [connection rootProxy];
	[serverObject performSelector:@selector(registerClient:)  
withObject:self];

 }...@catch(NSException *exception){
[self destroyConnection];
}
return serverObject;
}
-(void)ping{
NSLog(@server pinged);
}

Regards
SKiran
___

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

Please do not post 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: NSURLConnection unhappiness

2009-04-29 Thread Kyle Sluder
On Thu, Apr 30, 2009 at 1:44 AM, Jeff Johnson
publicpost...@lapcatsoftware.com wrote:
 On an unrelated note, your use of self-connection, etc., is non-standard
 and not advised. You should be using direct ivar access connection,
 properties self.connection, or accessor methods [self connection].

Sure, `self-connection` is redundant with just plain old
`connection`, but they amount to the same thing.  Unless there's some
new-runtime trickery going on that I'm not aware of.

--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: Building a 64-bit Preferences Pane

2009-04-29 Thread 慧 松本

Thanks!!

My problem was resolved at  https://devforums.apple.com/community/mac

Satoshi


On 2009/04/30, at 12:59, Clark Cox wrote:


2009/4/29 慧 松本 sato...@mac.com:


On 2009/04/30, at 12:05, Andrew Farmer wrote:


On 29 Apr 09, at 19:48, 慧 松本 wrote:


Does anybody know how to make 64-bit preference panes?


You can't, yet. The System Preferences application - which loads
preference panes as plugins - is still 32-bit only, so it can't  
load 64-bit

prefpane plugins.


Sorry, I forgot to mention my OS environment. I am developing the  
preference

pane on Mac OS X 10.6 Snow Leopard build 10A335.
Does my question violate NDA?


Take it to https://devforums.apple.com/community/mac

--
Clark S. Cox III
clarkc...@gmail.com


-
Satoshi Matsumoto sato...@mac.com
816-5 Odake, Odawara, Kanagawa, Japan 256-0802




___

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

Please do not post 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