Re: firewall api

2009-01-23 Thread Andrew Farmer

On 22 Jan 09, at 14:38, Chris Benedict wrote:
First, I'm pretty new to Mac OS X programming so please bear with my  
ignorance.


I was hoping to get a bit of quick advice.  I'm wanting to write a  
little application that will kind of put my MacBook in a lock down  
mode of sorts.  It would need to block/ignore all network traffic  
except for an app or two when you hit a button and then deactivate  
when you hit another button to return to the original settings.


My question is whether or not there is a public API to interact with  
the built-in firewall on Mac OS X 10.5 or if I would need to  
interface with system preferences somehow and just setup the  
firewall to block all connections except for the one app that I want  
to allow through or if there is a completely different way to go  
about doing this.  I found a program called Little Snitch which  
seems similar but way overkill for what I want to do and at first  
glance it looks like they do things with the drivers or something  
like that which honestly is above my head.


The built-in firewall is ipfw - the implementation on OS X is largely  
identical to the implementation in FreeBSD, so there's plenty of  
documentation online. I'm not aware of any specific API provided by  
Apple for managing the firewall, but the ipfw tool is probably good  
enough. Note that you'll need root privileges to use it.


The limit you're going to run into trying to write a tool like this is  
that you can't apply packet filters on a per-application level. The  
closest you can get is blocking packets which are addressed to  
specific ports, or which are destined for processes owned by specific  
users. Little Snitch accomplishes finer-grained restrictions by  
implementing a kernel extension; I do *NOT* recommend taking this  
approach unless you have a lot of spare time, and don't mind debugging  
kernel panics.

___

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

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

Help/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: Using the security framework

2009-01-23 Thread jonat...@mugginsoft.com


On 23 Jan 2009, at 05:05, Michael Ash wrote:


On Thu, Jan 22, 2009 at 10:15 PM, Joe Turner  wrote:


On Jan 22, 2009, at 4:57 PM, Nick Zitzmann wrote:



On Jan 22, 2009, at 4:09 PM, Joe Turner wrote:

I see. Then, how would you suggest to create a cloner/deleter, if  
it

needs root privileges, but cannot use the security framework?


I didn't say you couldn't use the security framework. I said you  
ought to

consider re-thinking your strategy.

And, since running scripts from root is dangerous, then is there  
any good
way to be able to delete protected (not your user account) files?  
Or, should

I just have it copy or delete files the user has access to?



There's nothing wrong with running scripts strictly as root, since  
a lot
of system scripts are run this way. But AEWP() doesn't run  
executables as
root; it runs them as the user with root privileges. There's an  
important

difference.

Instead of running a shell script, run another non-GUI command  
line tool
of your making with AEWP() that does the required privileged  
task(s).
Running shell code with root privileges as some user is possible,  
but it's

an easy attack vector due to the inheritance of the user's shell
environment. Running a command line tool is a bit more difficult  
to hack
(but still possible if someone is determined enough). Plus, then  
you can use

NSFileManager. :)

You could even take security to the extreme, as I once did in an
application, and check signatures before calling AEWP(), but  
that's probably

too extreme, as it's unlikely someone will rewrite or replace your
executable unless the file system gave them permission to do so.


Okay, I guess I should just put scheduling without needing the  
password to

the back of my queue.

I have one more question (sorry for all of these questions): If I  
call
AuthorizationCopyRights() every 280 (or anything less than 300  
secs) during
the clone, will it keep the authorization alive (no need to enter  
password

again)?


Don't do that. The standard way to accomplish a permanent unlock that
you're talking about is (I think) to have a suid root tool. You use
AEWP to run it as root so that it can become suid root, and after that
it simply *stays* suid root, as that's a filesystem property that
won't be disappearing spontaneously. As long as it's suid root you
don't need to touch AEWP again.

Of course you need to securely control access to your suid root tool
in that case, and I don't recall exactly how you do this, but I
believe the authorization APIs allow you to generate tokens that you
can pass to the tool to be checked for validity so that not just
anyone can come in and use the tool. And I'm pretty sure that Apple
has sample code to illustrate this. Definitely look at that sample
code no matter what; these APIs are ridiculously difficult to get
right, and you don't want to be working with them without a concrete
example sitting in front of you that you can crib from.

Another source of info on this would be Dalrymple + Hillegass -  
Advanced Mac OS X Programming.
It doesn't seem to be searchable on the web so you will need the  
physical papery object.


Chapter 17 covers the whole SUID/ticket business in detail (21 pages )  
with a working example.



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

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


Jonathan Mitchell

Central Conscious Unit
http://www.mugginsoft.com




___

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

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

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

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


Drag a custom subview inside a NSTableView

2009-01-23 Thread

Hello List,

I have a problem with a single column NSTableView. I populate the rows  
with my custom cell (a view  that includes NSProgress Indicator and  
textfields).
The point is that I cannot get to work the drag thing. I've been  
searching on the web and all I found was related to "regular" cells  
typically used by NSTableView. (TextFields, and so on)


I tried to find a work arround by:

a) Capturing the mouse events into the subview. This worked just fine,  
but only for the mouseDown event. For the mouseDragged, I could not  
get it to work... It seems like TableView is cutting this event to the  
subview.


b) Capturing the mouse events in the NSTableview. I fail too :(. I  
tried to subclass the scroll, the tableColumn with no success...)


Anybody have an idea about this


Thank you very much in advance!!!

Best,
Jose




___

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

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

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

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


Re: Problem assigning image to button under garbage collection

2009-01-23 Thread Rick Hoge


Bill, Rob -

Thanks for the replies, and sorry I missed this in the archives.

I have googled about such problems, but did not come up with  
anything.  Is there a known issue with images and buttons under GC?


Sounds odd.Please file a bug, attaching the application (binary  
is good enough unless you are comfortable attaching the source).


http://bugreporter.apple.com/



This has come up before and has been acknowledged as a bug in the  
Frameworks. It's apparently harmless (but yes, it's very annoying).


http://www.cocoabuilder.com/archive/message/xcode/2007/11/7/16932


The really bad thing about this is that the messages could mask real  
programming errors...  I had made a few changes to my code when I  
started getting the message, and also had made some cosmetic changes  
in IB (adding the button image).  I wasted a bunch of time reviewing  
my code changes before realizing it was the button image!


I suppose I should still add my voice to the bug reporter.

Cheers,

Rick
___

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

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

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

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


Re: What does errAuthorizationToolEnvironmentError mean?

2009-01-23 Thread Andy Lee

On Jan 22, 2009, at 11:03 PM, Jim Correia wrote:
I don't know why you are running into this problem. Chances are  
others might not know either. This is not a sanctioned/supported use  
of AEWP.


In other words, if the answer to the problem is to (repeatedly) call  
rm, cp, mv or chmod via AEWP, the problem is usually misdefined.


Generally, you want to factor out the code that needs elevated  
privileges into your own tool, and execute that using Authorization  
Services. There is sample code on developer.apple.com which does this.


Thanks, Jim.  I see advice on another thread as well to look at  
Apple's sample code.  In this case the "sample code" I looked at was  
code I inherited. :)


--Andy


___

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

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

Help/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 iPod icon, was Getting the network Machine Icon

2009-01-23 Thread Dave

Hi,

Is there some sample code anywhere that renders (e.g. applies the  
mask etc.) an Icon from a .icns file at a given resolution? I'd then  
like to be able to save the rendered image as a JPEG file.


If anyone knows of some sample code to get me going or can point me  
to the best starting place for this, I'd be really Grateful.


Thanks a lot

All the Best
Dave


___

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

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

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

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


Core Plot open source plotting framework

2009-01-23 Thread Drew McCormack
I am starting up a project on Google Code to hopefully create a first  
class open source Cocoa plotting framework for Mac and iPhone.
There is quite a lot of interest this time around, so I think the  
chance of success is very good. And, of course, we welcome other cocoa  
developers with open arms.


If you are interested, you can join the Google Group here: 
http://groups.google.com/group/coreplot-discuss

A high-level summary of our goals with the framework:

- Completely based on Core Animation (CALayer), rather than NSView or  
UIView. Will run on Mac and iPhone.
- Cool animations will be built into the framework from the beginning.  
eg transitions, builds.

- All standard 2D graphs: xy scatter, bar, even contour and image map.
- Layouts for multiple graphs
- Possibly equation typesetting
- Text and image annotations

Come join us!

--
Drew McCormack
http://www.macflashcards.com
http://www.macresearch.org
___

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

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

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

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


Re: Getting iPod icon, was Getting the network Machine Icon

2009-01-23 Thread Jean-Daniel Dupas


Le 23 janv. 09 à 14:29, Dave a écrit :


Hi,

Is there some sample code anywhere that renders (e.g. applies the  
mask etc.) an Icon from a .icns file at a given resolution? I'd then  
like to be able to save the rendered image as a JPEG file.


If anyone knows of some sample code to get me going or can point me  
to the best starting place for this, I'd be really Grateful.


Thanks a lot

All the Best
Dave



An icns file can be opened using NSImage methods.
Then choose the representation you need and convert it to JPEG as you  
would do with any image.


If you want to go the "hard" way (that is not that hard):
Use ReadIconFromFSRef() to load the icns file.
Convert it into an FSRef using GetIconRefFromIconFamilyPtr().
And then draw it using PlotIconRefInContext().

___

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

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

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

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


Encryption: Simplest method to encrypt a SQLite DB file...?

2009-01-23 Thread fclee
I would like to:
1) Encrypt/Encode a SQLite DB file from the command line (or via an 
application) and
2) De-Encrypt/Decode the same SQLite DB from within Cocoa/iPhone via a key of 
some sort.

Scenario:
   I'm developing a game using data values stored within a SQLite DB file.   I 
don't want hackers
to pry into the DB file and cheat the game; yet I need to occasionally update 
the SQLite DB file via 
importing MS Excel data.

   I'm thinking of encypting the DB file that is stored with the Application 
Bundle, then programmatically 
de-code it within a working directory to glean the contents; then remove the 
de-coded SQLite DB file.

   So the game data is stored as an encrypted SQLite DB file within the bundle, 
to be de-encrypted upon
game startup to load the environment variables.

Any (simple) ideas?

Ric.


___

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

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

Help/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: Encryption: Simplest method to encrypt a SQLite DB file...?

2009-01-23 Thread Jean-Daniel Dupas


Le 23 janv. 09 à 16:10, fc...@dialup4less.com a écrit :


I would like to:
1) Encrypt/Encode a SQLite DB file from the command line (or via an  
application) and
2) De-Encrypt/Decode the same SQLite DB from within Cocoa/iPhone via  
a key of some sort.


Scenario:
  I'm developing a game using data values stored within a SQLite DB  
file.   I don't want hackers
to pry into the DB file and cheat the game; yet I need to  
occasionally update the SQLite DB file via

importing MS Excel data.

  I'm thinking of encypting the DB file that is stored with the  
Application Bundle, then programmatically
de-code it within a working directory to glean the contents; then  
remove the de-coded SQLite DB file.


  So the game data is stored as an encrypted SQLite DB file within  
the bundle, to be de-encrypted upon

game startup to load the environment variables.


If this is an iPhone app, it should be signed, and AFAK, the iPhone is  
far more strict than Mac OS with tempered applications.
And so, you don't need to do something special to prevent resources  
modifications.


That said, the simplest way to crypt data on OS X is to use the  
CommonCrypto API. (see /usr/include/CommonCrypto/CommonCryptor.h)


And it look like this API is also available on iPhone (see the  
CryptoExercise sample code).



___

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

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

Help/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: Encryption: Simplest method to encrypt a SQLite DB file...?

2009-01-23 Thread Glenn L. Austin

On Jan 23, 2009, at 7:10 AM, fc...@dialup4less.com wrote:


I would like to:
1) Encrypt/Encode a SQLite DB file from the command line (or via an  
application) and
2) De-Encrypt/Decode the same SQLite DB from within Cocoa/iPhone via  
a key of some sort.


Scenario:
  I'm developing a game using data values stored within a SQLite DB  
file.   I don't want hackers
to pry into the DB file and cheat the game; yet I need to  
occasionally update the SQLite DB file via

importing MS Excel data.

  I'm thinking of encypting the DB file that is stored with the  
Application Bundle, then programmatically
de-code it within a working directory to glean the contents; then  
remove the de-coded SQLite DB file.


  So the game data is stored as an encrypted SQLite DB file within  
the bundle, to be de-encrypted upon

game startup to load the environment variables.

Any (simple) ideas?


What about storing it on an encrypted disk image?
___

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

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

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

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


[Solved] Re: Trust, but verify - OCUnit testing of Target-Action Connections

2009-01-23 Thread David H. Silber
On Mon, Jan 12, 2009 at 04:03:10PM -0500, David H. Silber wrote:
>   1) Is there not any way to test the connections set up in the nib
>   owned by the application?  In particular, the menus.
>   As things stand, I still end up with a bunch of untestable code.

I was able to test the connections set up in the application's nib file
by ditching the idea that they needed to be tested via OCUnit.  Instead,
I used NSAssert from within the application, making sure that the test
code is enabled only when the application is compiled with the Debug
configuration.

It may not sound like a big deal, but it was not obvious when I started
how this was to be accomplished.

This works, but it seems a bit clunky to me.  If anyone can suggest a
better way to do this, I would be interested.

Thanks,
David

P.S.  One thing I still don't understand is that the title of the
application menu displays correctly, but internally has the value
@"Apple".  Can anyone explain this?
___

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

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

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

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


Re: Encryption: Simplest method to encrypt a SQLite DB file...?

2009-01-23 Thread Michael Ash
On Fri, Jan 23, 2009 at 10:10 AM,   wrote:
> I would like to:
> 1) Encrypt/Encode a SQLite DB file from the command line (or via an 
> application) and
> 2) De-Encrypt/Decode the same SQLite DB from within Cocoa/iPhone via a key of 
> some sort.
>
> Scenario:
>   I'm developing a game using data values stored within a SQLite DB file.   I 
> don't want hackers
> to pry into the DB file and cheat the game; yet I need to occasionally update 
> the SQLite DB file via
> importing MS Excel data.

First let me say that you have two mutually exclusive requirements
here. EITHER you can stop hackers from looking at and changing the
file OR you can use the file, but you can't do both.

What you're trying to do is technically equivalent to DRM, and we all
know how well that works. If you put code on the user's system that
has enough information to decrypt the file then you have necessarily
given that user enough information to decrypt the file manually. You
can obfuscate the stuff, you can hide it, you can play games with it,
you can make it difficult, but you can never defeat a determined
hacker.

(And note that this goes just as much for the iPhone as for the Mac.
Yes, standard iPhones are pretty well locked down, but jailbroken
iPhones are as open as a desktop Mac and any hacker who wants to cheat
is just going to jailbreak.)

On to solutions, you basically have three:

1) Store encrypted blobs of data in the database.
2) Encrypt the entire database, decrypt it before using it.
3) Encrypt the entire database, decrypt on the fly and on demand.

1 is easy but loses a lot of the advantage of using a database in the
first place. 2 is also easy but makes it trivial for your adversary to
intercept your program while it has the decrypted database sitting
right there on disk as a standard SQLite file that he can modify using
standard command-line tools. Both of these would be done using
CommonCrypto as mentioned in another message.

3 is going to be tough to implement yourself and is going to require
modifying SQLite itself, I believe. If you search around you'll find a
couple of commercial solutions for it at pretty reasonable prices, so
depending on your needs and your financial situation that might be a
reasonable way to go.

But again, you can only make things harder, you can't actually stop
knowledgeable people from breaking your protection and getting at your
stuff anyway.

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: My objectcontroller is loosing its moc, but only with certain timing

2009-01-23 Thread Sean McBride
On 1/22/09 3:00 PM, Ben Trumbull said:

>> This happens when I close a window in my app, but only if I close it
>> _very_ soon after it is opened.  If I leave the window open for a few
>> 100 ms then there is no problem.  My app is garbage collected.  The
>> exception is happening after windowWillClose.
>>
>> The culprit seems to be an NSObjectController in the nib.  At this
>> point, nothing in my nib nor code even uses this objectController.  I
>> can stop the exception by doing one of two things:
>>
>> a) remove it's binding to my document's moc.  Instead, I call
>> [myController setManagedObjectContext:...] in awakeFromNib.
>>
>> b) change the 'prepares content' checkbox from on to off and instead
>> call [myController fetchWithRequest:nil merge:NO error:&error] in
>> windowDidLoad.
>>
>> Anyone understand what's happening?  Does it sound like a Cocoa bug?
>
>That's pretty weird, and yes it sounds like a bug in NSObjectController.
>
>If you can make a sample Xcode project that reproduces the problem and
>attach it to a bugreport.apple.com bug that would be very helpful.

It repros surprisingly easily in a simple app:


--

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


___

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

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

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

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


Re: Zombies: "Not a Type release"

2009-01-23 Thread Ken Ferry
On Thu, Jan 22, 2009 at 2:43 PM, Greg Parker  wrote:

> On Jan 22, 2009, at 2:15 PM, Sean McBride wrote:
>
>> On 1/22/09 2:11 PM, Alexander Heinz said:
>>
>>> *** -[Not A Type release]: message sent to deallocated instance
>>> 0xe412b30
>>>
>>> This doesn't tell me what kind of object is sent the message, so I'm
>>> having a very hard time debugging the problem.
>>>
>>> My questions are:
>>>
>>> What is a "Type release" (and, by extension, what does it mean to not
>>> be one)?
>>>
>>
>> I think you're reading that wrong.  Think:
>>
>> -["Not A Type" release]
>>
>> The message 'release' was sent to something... can you 'po
>> 0xe412b30' in gdb?  Or check the history of that address with Instruments?
>>
>
> "Not A Type" is the type name for the Core Foundation type with CFTypeID
> zero. That type isn't supposed to show up anywhere.
>
> If the object used to be an instance of a CF type, then you might get
> better information from CFZombie instead of NSZombie.


As of Leopard, NSZombieEnabled is fully functional for CFTypes, and I think
CFZombieLevel is dead.

-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: Getting iPod icon, was Getting the network Machine Icon

2009-01-23 Thread Dave

Hi Jean,

On 23 Jan 2009, at 13:56, Jean-Daniel Dupas wrote:

An icns file can be opened using NSImage methods.
Then choose the representation you need and convert it to JPEG as  
you would do with any image.


If you want to go the "hard" way (that is not that hard):
Use ReadIconFromFSRef() to load the icns file.
Convert it into an FSRef using GetIconRefFromIconFamilyPtr().
And then draw it using PlotIconRefInContext().



Thanks for this. After looking around, I decided to do it the 'hard"  
way, since I already have most of the wrapper code I can steal from  
another module.


I have a question on this through. How do I fill in the parameters to  
the GetIconRefFromIconFamilyPtr() call? This is my code so far:


(There may be a few typeo's in this, but it compiles ok)


CGContextRefmyBitMapContextRef;
CGBitMapInfomyBitMapInfo;
CGColorSpaceRef myColorSpaceRef;
CGRect  myImageRect;
size_t  myImageWidth;
size_t  myImageHeight;
size_t  myBitsPerComponent;
size_t  myNumberOfComponents;
size_t  myRowBytes;
char*   myImageBufferPtr;
RGBColormyLabelRGBColor:

IconFamilyHandlemyIconFamilyHandle;
IconRef myIconRef;

// myFSRef is setup ok at this point

myIconFamilyHandle = NULL;
myOSErr = ReadIconFromFSRef(&myFSRef,&myIconFamilyHandle);
if (myOSErr != noErr)
goto Error;

myOSErr = GetIconRefFromIconFamilyPtr 
(*myIconFamilyHandle,GetHandleSize(myIconFamilyHandle),&myIconRef);

if (myOSErr != noErr)
goto Error;

myBitMapInfo = kCGImageAlphaPremultipliedLast;
myImageWidth = 64;
myImageHeight = 64;
myBitsPerComponent = 8;
myNumberOfComponents = 4;
myRowBytes = COMPUTE_BEST_BYTES_PER_ROW(myImageWidth *  
(myBitsPerComponent / 8) * myNumberOfComponents);

myImageBufferPtr = malloc(myImageHeight, myRowBytes);
myColorSpaceRef = GCColorSpaceCreateWithName(kCGColorSpaceGenericRGB);

myBitMapContextRef = CGBitmapContextCreate 
(myImageBufferPtr,myImageWidth,myImageHeight,myBitsPerComponent,myRowByt 
es, myColorSpaceRef, myBitMapInfo);


CGContextClearRect(myBitMapContextRef,0,0,myWidth, myImageHeight)

myImageRect.origin.x = 0;
myImageRect.origin.y = 0;
myImageRect.size.width = myImageWidth;
myImageRect.size.height = myImageHeight;

myLabelRGBColor.red = 0;
myLabelRGBColor.green = 0;
myLabelRGBColor.blue = 0;
myOSErr = PlotIconRefInContext 
(myBitMapContextRef,&myImageRect,kAlignNone,kTransformNone,  
myLabelRGBColor,kPlotIconRefNormalFlags,myIconRef);


What should "myLabelRGBColor" be set to?

Also at this point, I'd like to get a pointer to the Pixel buffer in  
the CGContext and return this. The code I already have will write the  
JPEG file, all I need is a copy of the Pixel Data? Is there a way to  
do this?


Thanks a lot
All the Best
Dave


___

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

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

Help/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: Encryption: Simplest method to encrypt a SQLite DB file...? {iPhone}

2009-01-23 Thread fclee
Environment: iPhone

I'm particularly concerned with 'data viewing'.
Think of the data as answers to a quiz.   I worry that some
hacker could copy & distribute the data (rules) on the internet, and in essence,
cheat  the game.

Being that "... iPhone is far more restrictive towards tampering...",
Is it still possible to grab the SQLite DB file from the bundle to view its 
(uncoded) data?
If not, then there's no need to encrypt the SQLite DB file within the App 
Bundle.

Ric.

On 01/23/2009 07:44 Jean-Daniel Dupas wrote ..
>
> Le 23 janv. 09 à 16:10, fc...@dialup4less.com a écrit :
>
> > I would like to:
> > 1) Encrypt/Encode a SQLite DB file from the command line (or via an
> > application) and
> > 2) De-Encrypt/Decode the same SQLite DB from within Cocoa/iPhone via
> > a key of some sort.
> >
> > Scenario:
> >   I'm developing a game using data values stored within a SQLite DB
> > file.   I don't want hackers
> > to pry into the DB file and cheat the game; yet I need to
> > occasionally update the SQLite DB file via
> > importing MS Excel data.
> >
> >   I'm thinking of encypting the DB file that is stored with the
> > Application Bundle, then programmatically
> > de-code it within a working directory to glean the contents; then
> > remove the de-coded SQLite DB file.
> >
> >   So the game data is stored as an encrypted SQLite DB file within
> > the bundle, to be de-encrypted upon
> > game startup to load the environment variables.
>
> If this is an iPhone app, it should be signed, and AFAK, the iPhone is  <-- 
> 'AFAK' ?
> far more strict than Mac OS with tempered applications.
> And so, you don't need to do something special to prevent resources
> modifications.
>
> That said, the simplest way to crypt data on OS X is to use the
> CommonCrypto API. (see /usr/include/CommonCrypto/CommonCryptor.h)
>
> And it look like this API is also available on iPhone (see the
> CryptoExercise sample code).
___

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

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

Help/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: Encryption: Simplest method to encrypt a SQLite DB file...?

2009-01-23 Thread fclee
This is within an iPhone environment, where the entire game & logic rules
are stored within the application bundle.

We're using SQLite as the preferred storage 'bin'.  But I don't want
hackers peek inside and spoil the game.

I figured that I could encode the SQLite DB file via my MacBook Pro laptop
and add the encoded file to the (iPhone) application bundle.

Then I would programmatically decode the SQLite DB file and Query the data
from within the App.

But if iPhone's environment is tight/restrictive towards tampering/view
resources; then I'll all set.

Ric.

On 01/23/2009 07:52 Glenn L. Austin wrote ..
..
> What about storing it on an encrypted disk image?
___

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

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

Help/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: Encryption: Simplest method to encrypt a SQLite DB file...?

2009-01-23 Thread Dave

Hi,

Why not just en/de-crpyt the data as it is written/read to/from the  
database?


All the Best
Dave


On 23 Jan 2009, at 16:46, fc...@dialup4less.com wrote:

This is within an iPhone environment, where the entire game & logic  
rules

are stored within the application bundle.

We're using SQLite as the preferred storage 'bin'.  But I don't want
hackers peek inside and spoil the game.

I figured that I could encode the SQLite DB file via my MacBook Pro  
laptop

and add the encoded file to the (iPhone) application bundle.

Then I would programmatically decode the SQLite DB file and Query  
the data

from within the App.

But if iPhone's environment is tight/restrictive towards tampering/ 
view

resources; then I'll all set.

Ric.

On 01/23/2009 07:52 Glenn L. Austin wrote ..
..

What about storing it on an encrypted disk image?

___

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

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

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


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


Sliding Split Views, part II

2009-01-23 Thread Sam Krishna
I'm using the following code to create an animated sliding SplitView  
using an NSButton to toggle whether the split view is *up* and you can  
see the lower split view, or *down* and the lower split view is  
hidden.  Here's the code:


- (IBAction)toggleVariables:(id)sender
{
NSSize newSize = [detailSplit frame].size;

[NSAnimationContext beginGrouping];
[[NSAnimationContext currentContext] setDuration:.25];

if ([sender state] == NSOnState)
{
newSize.height = 4 * (newSize.height / 5);
[[theUpperSubView animator] setFrameSize:newSize];
newSize.height = (newSize.height / 5);
[[theLowerSubView animator] setFrameSize:newSize];
}
else if ([sender state] == NSOffState)
{
[[theUpperSubView animator] setFrameSize:newSize];
newSize.height = 0;
[[theLowerSubView animator] setFrameSize:newSize];
}

[NSAnimationContext endGrouping];
}

Currently, the above code animated the sliding split view as if it's  
opening, but it essentially *pushes* the top edge of theUpperSubView  
above the superview's top edge in the window.


I'd like to replicate the result that you see in Automator where, on  
the left-hand side of the main split view, when you click on the  
"Description View" button, the library view is essentially placed  
below/behind the DescriptionView. when it slides up as it's opening.  
To see this, open Automator, select any random Automator Action, and  
click the "View Description" button on the lower left-hand side of the  
document window.


TIA!

Live Playfully,

Sam
-
If he listens in faith,
finding no fault, a man is free
and will attain the cherished words
of those who act in virtue.

___

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

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

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

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


sqlite iphone question....

2009-01-23 Thread James Cicenia

Hello -

I am trying to get my simulator to work with sqlite and was wondering  
if I was missing some step?


Here is a snippet of code:

- (void)initializeDatabase {
NSMutableArray *items = [[NSMutableArray alloc] init];
self.produceItems = items;
[items release];

// The database is stored in the application bundle.
NSArray *paths =  
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,  
NSUserDomainMask, YES);

NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory  
stringByAppendingPathComponent:@"whatsfresh.sqlite"];



	// Open the database. The database was prepared outside the  
application.

if (sqlite3_open([path UTF8String], &database) == SQLITE_OK) {
NSLog(@"Open Database");
// Get the primary key for all produce.
const char *sql = "SELECT id FROM Item";
sqlite3_stmt *statement;
// Preparing a statement compiles the SQL query into a byte- 
code program in the SQLite library.
// The third parameter is either the length of the SQL string  
or -1 to read up to the first null terminator.
if (sqlite3_prepare_v2(database, sql, -1, &statement, NULL)  
== SQLITE_OK) {


NEVER GETS PAST THIS IF. I have queried the database and the data is  
in there?!


Thanks
James Cicenia
___

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

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

Help/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 iPod icon, was Getting the network Machine Icon

2009-01-23 Thread Jean-Daniel Dupas


Le 23 janv. 09 à 17:34, Dave a écrit :


Hi Jean,

On 23 Jan 2009, at 13:56, Jean-Daniel Dupas wrote:

An icns file can be opened using NSImage methods.
Then choose the representation you need and convert it to JPEG as  
you would do with any image.


If you want to go the "hard" way (that is not that hard):
Use ReadIconFromFSRef() to load the icns file.
Convert it into an FSRef using GetIconRefFromIconFamilyPtr().
And then draw it using PlotIconRefInContext().



Thanks for this. After looking around, I decided to do it the 'hard"  
way, since I already have most of the wrapper code I can steal from  
another module.


I have a question on this through. How do I fill in the parameters  
to the GetIconRefFromIconFamilyPtr() call? This is my code so far:


(There may be a few typeo's in this, but it compiles ok)





myIconFamilyHandle = NULL;
myOSErr = ReadIconFromFSRef(&myFSRef,&myIconFamilyHandle);
if (myOSErr != noErr)
goto Error;

myOSErr =  
GetIconRefFromIconFamilyPtr 
(*myIconFamilyHandle,GetHandleSize(myIconFamilyHandle),&myIconRef);

if (myOSErr != noErr)
goto Error;


look fine to me.


myBitMapInfo = kCGImageAlphaPremultipliedLast;
myImageWidth = 64;
myImageHeight = 64;
myBitsPerComponent = 8;
myNumberOfComponents = 4;
myRowBytes = COMPUTE_BEST_BYTES_PER_ROW(myImageWidth *  
(myBitsPerComponent / 8) * myNumberOfComponents);

myImageBufferPtr = malloc(myImageHeight, myRowBytes);
myColorSpaceRef = GCColorSpaceCreateWithName(kCGColorSpaceGenericRGB);

myBitMapContextRef =  
CGBitmapContextCreate 
(myImageBufferPtr 
,myImageWidth,myImageHeight,myBitsPerComponent,myRowBytes,  
myColorSpaceRef, myBitMapInfo);


CGContextClearRect(myBitMapContextRef,0,0,myWidth, myImageHeight)

myImageRect.origin.x = 0;
myImageRect.origin.y = 0;
myImageRect.size.width = myImageWidth;
myImageRect.size.height = myImageHeight;

myLabelRGBColor.red = 0;
myLabelRGBColor.green = 0;
myLabelRGBColor.blue = 0;
myOSErr =  
PlotIconRefInContext 
(myBitMapContextRef,&myImageRect,kAlignNone,kTransformNone,  
myLabelRGBColor,kPlotIconRefNormalFlags,myIconRef);


What should "myLabelRGBColor" be set to?


I think you can pass NULL for the label color.




Also at this point, I'd like to get a pointer to the Pixel buffer in  
the CGContext and return this. The code I already have will write  
the JPEG file, all I need is a copy of the Pixel Data? Is there a  
way to do this?


myImageBufferPtr is the pixel buffer.

To create the image, you can also use an NSImage,

NSImage *img = [[NSImage alloc] initWithSize:NSMakeSize(myImageWidth,  
myImageHeight)];

[img lockFocus]
CGContextRef ctxt = [[NSGraphicsContext currentContext] graphicPort];

// draw

[img unlockFocus]

And now, use NSImage function to save it as a JPEG. It's easier than  
dealing with all the bitmap stuff.


An other way may be to use CGBitmapContextCreateImage() to create a  
CGImageRef from your context, and then use ImageIO  
(CGImageDestinationRef) to export your image.








___

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

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

Help/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: Encryption: Simplest method to encrypt a SQLite DB file...? {iPhone}

2009-01-23 Thread Jean-Daniel Dupas


Le 23 janv. 09 à 17:41, fc...@dialup4less.com a écrit :


Environment: iPhone

I'm particularly concerned with 'data viewing'.
Think of the data as answers to a quiz.   I worry that some
hacker could copy & distribute the data (rules) on the internet, and  
in essence,

cheat  the game.

Being that "... iPhone is far more restrictive towards tampering...",
Is it still possible to grab the SQLite DB file from the bundle to  
view its (uncoded) data?


Yes. If you want to prevent reading, you cannot count on the signing  
system.


Note that you mention that you want to update the DB. If by that you  
mean, updating the DB and stored the new version in your bundle  
resources,  this is not a good idea.
It will break your signature, and will fail if the user does not have  
appropriate privileges.




If not, then there's no need to encrypt the SQLite DB file within  
the App Bundle.


Ric.

On 01/23/2009 07:44 Jean-Daniel Dupas wrote ..


Le 23 janv. 09 à 16:10, fc...@dialup4less.com a écrit :


I would like to:
1) Encrypt/Encode a SQLite DB file from the command line (or via an
application) and
2) De-Encrypt/Decode the same SQLite DB from within Cocoa/iPhone via
a key of some sort.

Scenario:
 I'm developing a game using data values stored within a SQLite DB
file.   I don't want hackers
to pry into the DB file and cheat the game; yet I need to
occasionally update the SQLite DB file via
importing MS Excel data.

 I'm thinking of encypting the DB file that is stored with the
Application Bundle, then programmatically
de-code it within a working directory to glean the contents; then
remove the de-coded SQLite DB file.

 So the game data is stored as an encrypted SQLite DB file within
the bundle, to be de-encrypted upon
game startup to load the environment variables.


If this is an iPhone app, it should be signed, and AFAK, the iPhone  
is  <-- 'AFAK' ?

far more strict than Mac OS with tempered applications.
And so, you don't need to do something special to prevent resources
modifications.

That said, the simplest way to crypt data on OS X is to use the
CommonCrypto API. (see /usr/include/CommonCrypto/CommonCryptor.h)

And it look like this API is also available on iPhone (see the
CryptoExercise sample code).


___

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

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

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

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


SQLite Math Functions?

2009-01-23 Thread James Cicenia

Does anyone know if sqlite on the iphone has math functions?

thanks
James Cicenia

___

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

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

Help/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: sqlite iphone question....

2009-01-23 Thread Keary Suska


On Jan 23, 2009, at 10:30 AM, James Cicenia wrote:


- (void)initializeDatabase {
NSMutableArray *items = [[NSMutableArray alloc] init];
self.produceItems = items;
[items release];

// The database is stored in the application bundle.
   NSArray *paths =  
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,  
NSUserDomainMask, YES);

   NSString *documentsDirectory = [paths objectAtIndex:0];
   NSString *path = [documentsDirectory  
stringByAppendingPathComponent:@"whatsfresh.sqlite"];


	// Open the database. The database was prepared outside the  
application.

   if (sqlite3_open([path UTF8String], &database) == SQLITE_OK) {
NSLog(@"Open Database");
// Get the primary key for all produce.
const char *sql = "SELECT id FROM Item";
   sqlite3_stmt *statement;
   // Preparing a statement compiles the SQL query into a byte- 
code program in the SQLite library.
   // The third parameter is either the length of the SQL string  
or -1 to read up to the first null terminator.
   if (sqlite3_prepare_v2(database, sql, -1, &statement, NULL)  
== SQLITE_OK) {


NEVER GETS PAST THIS IF. I have queried the database and the data is  
in there?!



Working with files in the app bundle like this may be a non-no. At  
least, it is for Mac OS X, and the emulator might have this issue. To  
know for sure, put the database file into the "sandbox" and see if it  
behaves better there.


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: Encryption: Simplest method to encrypt a SQLite DB file...? {iPhone}

2009-01-23 Thread Keary Suska


On Jan 23, 2009, at 9:41 AM, fc...@dialup4less.com wrote:


Environment: iPhone

I'm particularly concerned with 'data viewing'.
Think of the data as answers to a quiz.   I worry that some
hacker could copy & distribute the data (rules) on the internet, and  
in essence,

cheat  the game.

Being that "... iPhone is far more restrictive towards tampering...",
Is it still possible to grab the SQLite DB file from the bundle to  
view its (uncoded) data?
If not, then there's no need to encrypt the SQLite DB file within  
the App Bundle.



Also consider the iPhone backup with iTunes onto the Mac. Not sure how  
difficult those archives are to crack, or whether any attempt has even  
been made to prevent it.


Best,

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: sqlite iphone question....

2009-01-23 Thread James Cicenia

Hmmm,,, newbie here..

Where is the "sandbox?

Thanks
James

On Jan 23, 2009, at 11:39 AM, Keary Suska wrote:



On Jan 23, 2009, at 10:30 AM, James Cicenia wrote:


- (void)initializeDatabase {
NSMutableArray *items = [[NSMutableArray alloc] init];
self.produceItems = items;
[items release];

// The database is stored in the application bundle.
  NSArray *paths =  
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,  
NSUserDomainMask, YES);

  NSString *documentsDirectory = [paths objectAtIndex:0];
  NSString *path = [documentsDirectory  
stringByAppendingPathComponent:@"whatsfresh.sqlite"];


	// Open the database. The database was prepared outside the  
application.

  if (sqlite3_open([path UTF8String], &database) == SQLITE_OK) {
NSLog(@"Open Database");
// Get the primary key for all produce.
const char *sql = "SELECT id FROM Item";
  sqlite3_stmt *statement;
  // Preparing a statement compiles the SQL query into a byte- 
code program in the SQLite library.
  // The third parameter is either the length of the SQL string  
or -1 to read up to the first null terminator.
  if (sqlite3_prepare_v2(database, sql, -1, &statement, NULL)  
== SQLITE_OK) {


NEVER GETS PAST THIS IF. I have queried the database and the data  
is in there?!



Working with files in the app bundle like this may be a non-no. At  
least, it is for Mac OS X, and the emulator might have this issue.  
To know for sure, put the database file into the "sandbox" and see  
if it behaves better there.


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: sqlite iphone question....

2009-01-23 Thread mmalc Crawford


On Jan 23, 2009, at 9:52 AM, James Cicenia wrote:


Where is the "sandbox?




mmalc

___

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

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

Help/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: sqlite iphone question....

2009-01-23 Thread James Cicenia

thanks

On Jan 23, 2009, at 11:59 AM, mmalc Crawford wrote:



On Jan 23, 2009, at 9:52 AM, James Cicenia wrote:


Where is the "sandbox?




mmalc



___

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

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

Help/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: sqlite iphone question....

2009-01-23 Thread James Cicenia

Hmmm,,,

OK I read the docs a bit.. and now I am confused. This code snippet  
was basically copied and pasted from the sqlbook example.

It works when I run it in the simulator.

Mine .. .does get past the open database, but doesn't really get past  
the select.


I also don't quite understand where I should set or copy  
mydatabase.sqlite. It is in the Resource group and in the target  
already.


Confused
James Cicenia


On Jan 23, 2009, at 11:39 AM, Keary Suska wrote:



On Jan 23, 2009, at 10:30 AM, James Cicenia wrote:


- (void)initializeDatabase {
NSMutableArray *items = [[NSMutableArray alloc] init];
self.produceItems = items;
[items release];

// The database is stored in the application bundle.
  NSArray *paths =  
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,  
NSUserDomainMask, YES);

  NSString *documentsDirectory = [paths objectAtIndex:0];
  NSString *path = [documentsDirectory  
stringByAppendingPathComponent:@"whatsfresh.sqlite"];


	// Open the database. The database was prepared outside the  
application.

  if (sqlite3_open([path UTF8String], &database) == SQLITE_OK) {
NSLog(@"Open Database");
// Get the primary key for all produce.
const char *sql = "SELECT id FROM Item";
  sqlite3_stmt *statement;
  // Preparing a statement compiles the SQL query into a byte- 
code program in the SQLite library.
  // The third parameter is either the length of the SQL string  
or -1 to read up to the first null terminator.
  if (sqlite3_prepare_v2(database, sql, -1, &statement, NULL)  
== SQLITE_OK) {


NEVER GETS PAST THIS IF. I have queried the database and the data  
is in there?!



Working with files in the app bundle like this may be a non-no. At  
least, it is for Mac OS X, and the emulator might have this issue.  
To know for sure, put the database file into the "sandbox" and see  
if it behaves better there.


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: Sliding Split Views, part II

2009-01-23 Thread Erik Buck
As I recall, this sample code does exactly what you want:
http://developer.apple.com/samplecode/Reducer/
 
I haven't looked at it for a while, so I may be mistaken.
___

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

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

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

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


NSNumberFormatter setFormat: in 10.3.9

2009-01-23 Thread Jonathan Fewtrell
My app, developed on 10.5 but targeted at 10.3.9 and above, contains  
the following code:


NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
[formatter setFormat:@"#0;#0;#0"];

It compiles without warnings.

When running on 10.3.9 it crashes with EXC_BAD_ACCESS in - 
[NSNumberFormatter setFormat:]. It works fine on 10.4 and 10.5.


For such a simple bit of code, I struggle to see what could be wrong.  
A previous version, developed on 10.4, did not show this problem, so  
I'm wondering if it's a build setting problem. If it is, I can't see  
which one.


I can see from the archives that NSNumberFormatter has various issues,  
but they do not seem to me to be relevant here.


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

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


Re: sqlite iphone question....

2009-01-23 Thread Dave DeLong
I would REALLY recommend using some sort of wrapper class for sqlite,  
instead of using the functions yourself.  Why put yourself through the  
pain when someone else already has?


Here are the ones I would recommend:
http://th30z.netsons.org/2008/11/objective-c-sqlite-wrapper/
http://code.google.com/p/flycode/

Dave

On Jan 23, 2009, at 11:12 AM, James Cicenia wrote:


Hmmm,,,

OK I read the docs a bit.. and now I am confused. This code snippet  
was basically copied and pasted from the sqlbook example.

It works when I run it in the simulator.

Mine .. .does get past the open database, but doesn't really get  
past the select.


I also don't quite understand where I should set or copy  
mydatabase.sqlite. It is in the Resource group and in the target  
already.


Confused
James Cicenia


On Jan 23, 2009, at 11:39 AM, Keary Suska wrote:



On Jan 23, 2009, at 10:30 AM, James Cicenia wrote:


- (void)initializeDatabase {
NSMutableArray *items = [[NSMutableArray alloc] init];
self.produceItems = items;
[items release];

// The database is stored in the application bundle.
 NSArray *paths =  
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,  
NSUserDomainMask, YES);

 NSString *documentsDirectory = [paths objectAtIndex:0];
 NSString *path = [documentsDirectory  
stringByAppendingPathComponent:@"whatsfresh.sqlite"];


	// Open the database. The database was prepared outside the  
application.

 if (sqlite3_open([path UTF8String], &database) == SQLITE_OK) {
NSLog(@"Open Database");
// Get the primary key for all produce.
const char *sql = "SELECT id FROM Item";
 sqlite3_stmt *statement;
 // Preparing a statement compiles the SQL query into a byte- 
code program in the SQLite library.
 // The third parameter is either the length of the SQL string  
or -1 to read up to the first null terminator.
 if (sqlite3_prepare_v2(database, sql, -1, &statement, NULL)  
== SQLITE_OK) {


NEVER GETS PAST THIS IF. I have queried the database and the data  
is in there?!



Working with files in the app bundle like this may be a non-no. At  
least, it is for Mac OS X, and the emulator might have this issue.  
To know for sure, put the database file into the "sandbox" and see  
if it behaves better there.


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

This email sent to davedel...@me.com


___

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

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

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

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


Start traces with CrashReporter

2009-01-23 Thread Jules Colding

Hi,

Is there any way to make CrashReporter show stack frame content and  
line numbers instead of signatures and offsets? Maybe a way to make  
gdb automatically attach to crashing processes and do a "t a a bt f"  
on them?


Thanks,
  jules

___

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

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

Help/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 iPod icon, was Getting the network Machine Icon

2009-01-23 Thread Dave

Hi Jean,

Thank you so much for your help. I've almost got the code in place  
now. But please see below.


On 23 Jan 2009, at 17:33, Jean-Daniel Dupas wrote:







Also at this point, I'd like to get a pointer to the Pixel buffer  
in the CGContext and return this. The code I already have will  
write the JPEG file, all I need is a copy of the Pixel Data? Is  
there a way to do this?


myImageBufferPtr is the pixel buffer.

To create the image, you can also use an NSImage,

NSImage *img = [[NSImage alloc] initWithSize:NSMakeSize 
(myImageWidth, myImageHeight)];

[img lockFocus]
CGContextRef ctxt = [[NSGraphicsContext currentContext] graphicPort];

// draw

[img unlockFocus]

And now, use NSImage function to save it as a JPEG. It's easier  
than dealing with all the bitmap stuff.


An other way may be to use CGBitmapContextCreateImage() to create a  
CGImageRef from your context, and then use ImageIO  
(CGImageDestinationRef) to export your image.


The requirement of the function I am writing has now changed because  
I found a different way of doing it that requires much less changes  
to the rest of the application. Basically there is a framework of  
sorts that calls my function (GetIconImage), all I have to do is to  
render the Icon into a BitMap/PixMap and then return a pointer to it  
from my function, e.g. the function that calls my function need to  
return a buffer that is width * height * 4 in size that contains the  
pixels and everything else will be taken care of!


So, I if change the bit that computes the Row Bytes value so it is  
(width * 4) and change the malloc to malloc(width * height * 4) then  
just return myImageBufferPtr, this should be ok?


Also, how to I free the memory allocated by myBitMapContextRef,  
myIconRef and myIconFamily Icon? I can't seem to find dispose/release  
functions for these objects.


Thanks again, you have been a great help!

All the Best
Dave


___

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

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

Help/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: Log4Cocoa

2009-01-23 Thread Timothy Reaves


On Jan 22, 2009, at 1:54 PM, Kyle Sluder wrote:


On Thu, Jan 22, 2009 at 11:53 AM, Timothy Reaves
 wrote:
  There are a number of reasons to use Log4Cocoa over something  
like

ASL.  The fact that it already supports Obj-C is the least of them.
* It supports various logging levels,


As does ASL.


* supports logging to other than the default system file,


ASL does this too.

* different logging levels for different classes.  This is a  
biggie, as
often when you are debugging, you want to see very detailed log  
messages,

but only for the class or subsystem of interest.


I think it's important to remember that ASL is a key-value store, not
your traditional dump to a tab-delimited logfile.  You can log any set
of key-value pairs you want and filter it later.

--Kyle Sluder




	Yes, you can filter.  But you still have that huge amount of  
information that was logged, taking up space, and having a huge  
negative impact to performance.  ASL just doesn't cut it, without  
tones of extra code.

___

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

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

Help/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: Start traces with CrashReporter

2009-01-23 Thread Jean-Daniel Dupas

It already does it if debug symbols are available.

For example:

3   libnspr.4.dylib   			0x00090636 PR_CreateFileMap + 0  
(prmmap.c:52)
4   libnss.3.dylib			0x002b9601  
PK11_GetInternalKeySlot + 74 (pk11slot.c:1659)
5   org.shadowlab.MyLibrary  	0x00052b5f -[KIService  
createCertificate:] + 142 (KIService.m:46)
6   org.shadowlab.MySoftware  0x2b9d - 
[MKIAuthorityDocument editorDidEnd:result:context:] + 193  
(MKIAuthorityDocument.m:54)
7   com.apple.AppKit  		0x964ea233 -[NSApplication  
endSheet:returnCode:] + 288
8   org.shadowlab.MySoftware  0x7578 -[WBWindowController  
close:] + 140 (WBWindowController.m:62)
9   org.shadowlab.MySoftware  0x4086 -[MKIRequestEditor  
ok:] + 660 (MKIRequestEditor.m:206)



Le 23 janv. 09 à 19:45, Jules Colding a écrit :


Hi,

Is there any way to make CrashReporter show stack frame content and  
line numbers instead of signatures and offsets? Maybe a way to make  
gdb automatically attach to crashing processes and do a "t a a bt f"  
on them?


Thanks,
 jules

___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/devlists%40shadowlab.org

This email sent to devli...@shadowlab.org



___

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

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

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

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


Re: Getting iPod icon, was Getting the network Machine Icon

2009-01-23 Thread Jean-Daniel Dupas


Le 23 janv. 09 à 19:53, Dave a écrit :


Hi Jean,

Thank you so much for your help. I've almost got the code in place  
now. But please see below.


On 23 Jan 2009, at 17:33, Jean-Daniel Dupas wrote:







Also at this point, I'd like to get a pointer to the Pixel buffer  
in the CGContext and return this. The code I already have will  
write the JPEG file, all I need is a copy of the Pixel Data? Is  
there a way to do this?


myImageBufferPtr is the pixel buffer.

To create the image, you can also use an NSImage,

NSImage *img = [[NSImage alloc]  
initWithSize:NSMakeSize(myImageWidth, myImageHeight)];

[img lockFocus]
CGContextRef ctxt = [[NSGraphicsContext currentContext] graphicPort];

// draw

[img unlockFocus]

And now, use NSImage function to save it as a JPEG. It's easier  
than dealing with all the bitmap stuff.


An other way may be to use CGBitmapContextCreateImage() to create a  
CGImageRef from your context, and then use ImageIO  
(CGImageDestinationRef) to export your image.


The requirement of the function I am writing has now changed because  
I found a different way of doing it that requires much less changes  
to the rest of the application. Basically there is a framework of  
sorts that calls my function (GetIconImage), all I have to do is to  
render the Icon into a BitMap/PixMap and then return a pointer to it  
from my function, e.g. the function that calls my function need to  
return a buffer that is width * height * 4 in size that contains the  
pixels and everything else will be taken care of!


So, I if change the bit that computes the Row Bytes value so it is  
(width * 4) and change the malloc to malloc(width * height * 4) then  
just return myImageBufferPtr, this should be ok?


Yes. You should release the CGContext too. If you provide a buffer  
when you create it (this is what you do), your are responsible to free  
it, and so, releasing the bitmap context will not affect it.





Also, how to I free the memory allocated by myBitMapContextRef,  
myIconRef and myIconFamily Icon? I can't seem to find dispose/ 
release functions for these objects.


All CG type are CoreFoundation objects. So you can use CFRelease to  
free the bitmap context. There is also a CGContextRelease function but  
the doc says that this function is equivalent to CFRelease, except  
that it does not cause an error if the context parameter is NULL.


For the IconRef, the function is ReleaseIconRef().

And the icon family is an handle, and should be freed using  
DisposeHandle().





Thanks again, you have been a great help!

All the Best
Dave


___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/devlists%40shadowlab.org

This email sent to devli...@shadowlab.org



___

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

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

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

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


Re: Start traces with CrashReporter

2009-01-23 Thread Jean-Daniel Dupas

OK, this does not contains as much info as you want.

depending your need, you may activate core dump generation. So you  
will be able to launch gdb on the dump to retreive the info you need.


http://developer.apple.com/technotes/tn2004/tn2124.html#SECCOREDUMPS


Le 23 janv. 09 à 20:18, Jean-Daniel Dupas a écrit :


It already does it if debug symbols are available.

For example:

3   libnspr.4.dylib   			0x00090636 PR_CreateFileMap + 0  
(prmmap.c:52)
4   libnss.3.dylib			0x002b9601  
PK11_GetInternalKeySlot + 74 (pk11slot.c:1659)
5   org.shadowlab.MyLibrary  	0x00052b5f -[KIService  
createCertificate:] + 142 (KIService.m:46)
6   org.shadowlab.MySoftware  0x2b9d - 
[MKIAuthorityDocument editorDidEnd:result:context:] + 193  
(MKIAuthorityDocument.m:54)
7   com.apple.AppKit  		0x964ea233 -[NSApplication  
endSheet:returnCode:] + 288
8   org.shadowlab.MySoftware  0x7578 - 
[WBWindowController close:] + 140 (WBWindowController.m:62)
9   org.shadowlab.MySoftware  0x4086 -[MKIRequestEditor  
ok:] + 660 (MKIRequestEditor.m:206)



Le 23 janv. 09 à 19:45, Jules Colding a écrit :


Hi,

Is there any way to make CrashReporter show stack frame content and  
line numbers instead of signatures and offsets? Maybe a way to make  
gdb automatically attach to crashing processes and do a "t a a bt  
f" on them?


Thanks,
jules

___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/devlists%40shadowlab.org

This email sent to devli...@shadowlab.org



___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/devlists%40shadowlab.org

This email sent to devli...@shadowlab.org



___

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

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

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

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


Re: Receiving user events from within an NSTimer callback

2009-01-23 Thread John Mikros
Thanks so much for the responses!  Indeed calling  
nextEventMatchingMask... and sending the event manually worked.


Interesting info about the event loop being separate from (but linked  
to) the runloop.


Thanks again -- this was a lifesaver :)


On Jan 22, 2009, at 9:02 PM, Michael Ash wrote:


On Thu, Jan 22, 2009 at 7:34 PM, Quincey Morris
 wrote:

On Jan 22, 2009, at 14:55, John Mikros wrote:

I'm working on a Cocoa application which does all of its work  
within an
NSTimer callback that is called regularly.  Events are handled  
normally

within a Cocoa run loop.

However, there are times when within the callback, the code enters  
an

inner loop, and will not exit until some user action is performed.
I'm trying to force the run loop to pump events within this inner  
loop,

but I can't seem to ever get it to work.


I use, from the timer callback:


  NSEvent *event;
  while (event = [NSApp nextEventMatchingMask: NSAnyEventMask
untilDate: nil inMode: NSEventTrackingRunLoopMode dequeue: YES])
  [NSApp sendEvent: event];



I don't know if this is officially blessed or not, but it certainly  
seems to

work just fine.

In the places I've done this, I was only really interested in  
making the
mouse and keyboard work, hence NSEventTrackingRunLoopMode. You  
could use the

default run loop mode instead, I guess.


Yes, this is fine, and supported. It's a common way of implementing
mouse tracking instead of relying on the stateless mouseDragged:
method.

The reason you have to do this and can't just run the runloop is
because the event loop is actually a separate concept from the
runloop. It's a bit confusing because the event loop is implemented
using the runloop, but if you just run the runloop on the main thread,
events won't get processed. You have to explicitly run this in order
to get them to be processed.

Note that using the default runloop mode with this is generally a bad
idea. By running in the default mode you allow *everything* else to
run, which means that some other code might decide that *it* wants an
inner event loop as well. If you then want to quit before that other
code has finished, tough cookies. Much better to control things more
tightly by using a different runloop mode.

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/jmikros 
%40blizzard.com


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


Turn autosaving on forever - is it OK?

2009-01-23 Thread Vitaly Ovchinnikov
Hello list,

I implemented autosaving via -setAutosavingDelay call of
NSDocumentController. I placed checkbox that allows to enable or
disable autosaving in preferences and now think about removing this
checkbox and leave autosaving enabled forever. Will I have any
problems in that case? Maybe in some cases it is better to allow user
to disable autosaving. Please share your experience.

Thank you.
___

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

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

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

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


Re: NSCaledarDate's deprecation

2009-01-23 Thread kvic...@pobox.com

At Thu, 22 Jan 2009 23:13:45 +, Benjamin Dobson wrote:

On 22 Jan 2009, at 22:52:56, kvic...@pobox.com wrote:

 in anticipation of the deprecation of NSCaledarDate, i am in the 
 process of converting my app to use NSDate and friends. and while 
 the process is mostly straightforward and not all that difficult, it 
 is tedious.


 when i think i'm done, i'd like to be able to do a fresh build and
 > if possible have the compiler tell me any places i might have 
 missed... these would be places where i used a method of 
 NSCalendarDate that i missed with all my text searches.


 is there anyway to get the compiler to do this for me?


If you delete all occurrences of NSCalendarDate and what relevant code 
you can see, the compiler will pick up on undefined variables.


i'm not concerned with "lagging" instances of the text 
"NSCalendarDate" as i'm pretty sure i can find and fix all of them. i 
am concerned with missing a call to a method of NSCalendarDate. if 
this were a class of my own, then i would simply remove the .h/.m 
files from my project and the compiler would then tell me of any 
erroneous calls. but i can't do that with cocoa files/classes. and 
since NSCalendarDate is a subclass of NSDate, using an NSCalendarDate 
method on an NSDate object is perfectly legal at compile time. and 
this is what i'd like to catch at compile time, especially if i have 
(erroneously) cast an NSDate object to id in the past.


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: Start traces with CrashReporter

2009-01-23 Thread Jules Colding


On 23/01/2009, at 20.33, Jean-Daniel Dupas wrote:


OK, this does not contains as much info as you want.

depending your need, you may activate core dump generation. So you  
will be able to launch gdb on the dump to retreive the info you need.


http://developer.apple.com/technotes/tn2004/tn2124.html#SECCOREDUMPS


Yes, that is my thought too. Now I just have to wait for a crash ;-)

Thanks,
  jules

___

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

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

Help/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: Log4Cocoa

2009-01-23 Thread Joel Norvell
This doesn't answer the original question, but I believe it is pertinent to 
this thread.

It is also possible to log from within Xcode, something I hadn't realized until 
I saw the video of an excellent talk Joar Wingfors gave at a Silicon Valley 
Cocoaheads.

Joel

http://video.google.com/videoplay?docid=3598467380866353869

http://theocacao.com/downloads/DebuggingWithXcode.pdf




  
___

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

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

Help/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: Encryption: Simplest method to encrypt a SQLite DB file...? {iPhone}

2009-01-23 Thread Scott Ribe
> Also consider the iPhone backup with iTunes onto the Mac. Not sure how
> difficult those archives are to crack, or whether any attempt has even
> been made to prevent it.

Not difficult at all. There are utilities to do this, to allow users to
extract files and email them to devs for debug purposes.

-- 
Scott Ribe
scott_r...@killerbytes.com
http://www.killerbytes.com/
(303) 722-0567 voice


___

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

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

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

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


Re: Start traces with CrashReporter

2009-01-23 Thread Scott Ribe
> Yes, that is my thought too. Now I just have to wait for a crash ;-)

And that's why my app contains this gem:

- (IBAction) crashNow: (id) sender
{ *(char*)0=0; }


-- 
Scott Ribe
scott_r...@killerbytes.com
http://www.killerbytes.com/
(303) 722-0567 voice


___

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

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

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

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


Accessing private members of another object of the same class

2009-01-23 Thread Horst Jäger


Hi,


suppose I have a class with a private member as listed at the end of  
this email.


Then I can access it by calling its name without an accessor function  
(which would de facto make it public).


But how do I access a private member of another  object of the same  
class?



Or does Objective C have another concept of "private" than C/C++ ?


Thanks in advance

Horst




PrivateClass.h



@interface PrivateClass : NSObject {

@private int mineAlone;

}

-(int)yoursToo;
-(int)yoursTooButWithAnother: (PrivateClass *)another;


@end



 PrivateClass.m



#import "Private.h"


@implementation PrivateClass

-(int)yoursToo{

// access via name works

return mineAlone % 3;

// I cant't use
// return [self mineAlone]
// using a getter function
// because that would make
// mineAlone accessible for
// everyone since a method
// can't be declared private

}

-(int)yoursTooButWithAnother: (PrivateClass *)another;

// what am I to do?
// return another.mineAlone % 3;
// won't work and
// return [another mineAlone] % 3;
// would de facto make it public

}

@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: NSTextView and front/middle/back ellipses

2009-01-23 Thread Harry Plate
Randall,


>> How can I tell NSTextView to use a "front" or "middle" ellipses for
>> viewing
>> purposes?
> 
> You'll have to set a (mutable) paragraph style, and specify
> NSLineBreakByTruncatingHead or NSLineBreakByTruncatingMiddle for the
> NSLineBreakMode using -setLineBreakMode:.

Thanks a bunch! The hint led me to "Breaking Lines by Truncation" in the
"Rulers and Paragraph Styles" doc. Within that are some very useful code
fragments illustrating what to do.

I'm off to the races,

-harry


___

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

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

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

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


Caution Icon

2009-01-23 Thread Felix Ulber
Hi,
is there any way to get the caution icon badged with the application
icon like the NSRunCriticalAlertPanel/NSAlert with critical style uses?
I need to use a higly customized alert panel and would like to use that
big fat yellow exclamation mark.

regards
Felix
___

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

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

Help/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: NSNumberFormatter setFormat: in 10.3.9

2009-01-23 Thread Neil Allain
I believe that in 10.5, the default formatter behavior is 10.4 instead  
of 10.0 (in 10.4 the default behavior was still 10.0).  Check out:


http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/DataFormatting/DataFormatting.html

Neil

On Jan 23, 2009, at 12:30 PM, Jonathan Fewtrell wrote:

My app, developed on 10.5 but targeted at 10.3.9 and above, contains  
the following code:


NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
[formatter setFormat:@"#0;#0;#0"];

It compiles without warnings.

When running on 10.3.9 it crashes with EXC_BAD_ACCESS in - 
[NSNumberFormatter setFormat:]. It works fine on 10.4 and 10.5.


For such a simple bit of code, I struggle to see what could be  
wrong. A previous version, developed on 10.4, did not show this  
problem, so I'm wondering if it's a build setting problem. If it is,  
I can't see which one.


I can see from the archives that NSNumberFormatter has various  
issues, but they do not seem to me to be relevant here.


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

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


Dynamically set UILabel position ?

2009-01-23 Thread Zhao Wang
Hi, Folks,

I am new to iphone development. Now I am writing some small application for
study..

I wonder if there is a way I can dynamically set UILabel Position. for
example, based on user's input of the location? (Or dynamically set the
position an control which will display some text message, not necessary to
be UILabel)

Any suggestion? Thanks in advance!

Sincerely,
Zhao Wang
___

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

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

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

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


Drag the whole window just by dragging the Image placed on it?

2009-01-23 Thread Rahulkumar
Hi All,

 

I can move a Window i.e. a NSWindow object with the just a simple call
[myWindow setMovableByWindowBackground:TRUE]. This makes window movable from
every point I drag my mouse pointer. Now if I place an NSImage Object over
the window and try to drag the whole window there by only dragging the Image
, it does not works. 

Is there is any way to drag the whole window just by dragging the Image
placed on it?

 

Thanks in advance!

 

Regards,

Rahul 

 

___

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

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

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

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


hide a tabBar

2009-01-23 Thread Emmanuel Pinault

hi

I am using a TabBarViewController that had inside 2 Navigation  
Controller that have themselves a UIViewController.


I trying hide the tabBar when I am pushing new views using 	 
self.hidesBottomBarWhenPushed = YES;


To be more specific: I create the TabBarViewController using IB and  
template from Xcode for the iphone.


I have create a class  call FirstViewController and created its look  
using a Nib file.


In the viewDidLoad, I set the following

self.hidesBottomBarWhenPushed = YES;


And now when I push new views... nothing happens... How am I suppose  
to hide the tabBar? I tried to access the instance of that tabBar and  
call the hidden method but it only was hidding it partially (just the  
button) but the background of the bar was still there...


any help would be appreciated


Emmanuel
___

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

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

Help/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: Caution Icon

2009-01-23 Thread jonat...@mugginsoft.com


On 23 Jan 2009, at 13:55, Felix Ulber wrote:


Hi,
is there any way to get the caution icon badged with the application
icon like the NSRunCriticalAlertPanel/NSAlert with critical style  
uses?
I need to use a higly customized alert panel and would like to use  
that

big fat yellow exclamation mark.



NSImage *defaultImage = [[NSWorkspace sharedWorkspace]  
iconForFileType:NSFileTypeForHFSTypeCode(kAlertNoteIcon)];


you can also look at the Apple iconcollection sample.
iconscore.h lists the various icon constants.


regards
Felix
___

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

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

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

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


Jonathan Mitchell

Central Conscious Unit
http://www.mugginsoft.com




___

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

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

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

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


Re: Dynamically set UILabel position ?

2009-01-23 Thread Andy Lee
UILabel inherits from UIView and therefore has a frame property.  Try  
setting the UILabel's frame.


--Andy

On Jan 23, 2009, at 4:37 PM, Zhao Wang wrote:


Hi, Folks,

I am new to iphone development. Now I am writing some small  
application for

study..

I wonder if there is a way I can dynamically set UILabel Position. for
example, based on user's input of the location? (Or dynamically set  
the
position an control which will display some text message, not  
necessary to

be UILabel)

Any suggestion? Thanks in advance!

Sincerely,
Zhao Wang
___

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

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

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

This email sent to ag...@mac.com


___

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

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

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

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


Re: Drag the whole window just by dragging the Image placed on it?

2009-01-23 Thread Luca
Hmm, i would subclass NSImage making it sending data to its window.   
But...I'm curious to see how others would do this.


Luca C.


Il giorno 23/gen/09, alle ore 10:54, "Rahulkumar" > ha scritto:



Hi All,



I can move a Window i.e. a NSWindow object with the just a simple call
[myWindow setMovableByWindowBackground:TRUE]. This makes window  
movable from
every point I drag my mouse pointer. Now if I place an NSImage  
Object over
the window and try to drag the whole window there by only dragging  
the Image

, it does not works.

Is there is any way to drag the whole window just by dragging the  
Image

placed on it?



Thanks in advance!



Regards,

Rahul



___

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

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

___

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

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

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

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


Core Animation

2009-01-23 Thread David Blanton

I have gone over the CA docs ... a quick read.

I have an iPhone app that uses the accelerometer to move a puck  
around the x,y plane.  It filters out the effect of gravity per the  
sample code.


I would like to animate two background layers, one rotating cw the  
other ccw and use different  CG blends based on the current location  
of the puck.


Do I need to make the animation in a separate thread or does CA  
handle that for me? I.e. I need responsiveness from the accelerometer  
and the visual effect of the rotating backgrounds/


David Blanton





___

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

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

Help/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: Accessing private members of another object of the same class

2009-01-23 Thread Quincey Morris

On Jan 23, 2009, at 13:01, Horst Jäger wrote:

But how do I access a private member of another  object of the same  
class?


Like this:


-(int)yoursTooButWithAnother: (PrivateClass *)another {
return another->mineAlone % 3;
}


Also, be careful to keep two things separate in your mind.

-- The *variable* mineAlone, which can be referenced in the class's  
methods as 'mineAlone' or 'self->mineAlone'.


-- The *property* mineAlone, which can be referenced in the class's  
methods as '[self mineAlone]' or 'self.mineAlone'.


They only "accidentally" have the same name.


___

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

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

Help/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: Accessing private members of another object of the same class

2009-01-23 Thread Ken Thomases

On Jan 23, 2009, at 3:01 PM, Horst Jäger wrote:

suppose I have a class with a private member as listed at the end of  
this email.


Then I can access it by calling its name without an accessor  
function (which would de facto make it public).


But how do I access a private member of another  object of the same  
class?



@interface PrivateClass : NSObject {

@private int mineAlone;

}

-(int)yoursToo;
-(int)yoursTooButWithAnother: (PrivateClass *)another;

@end



@implementation PrivateClass

-(int)yoursToo{

// access via name works

return mineAlone % 3;

// I cant't use
// return [self mineAlone]
// using a getter function
// because that would make
// mineAlone accessible for
// everyone since a method
// can't be declared private


There's no real way to enforce privateness, either in Objective-C or C+ 
+.  Generally, you have to trust the code which uses your class to  
some extent.  The typical approach is to merely make sure that the  
other code gets a warning from the compiler if they do something they  
shouldn't.


In Objective-C, this is accomplished by not declaring the method in  
the header.  In the implementation, you can define it above where you  
use it.  Or, you can use Objective-C 2.0 class extensions to declare  
it.  Or, prior to Objective-C 2.0, you can define a category in  
your .m file to declare it.



}

-(int)yoursTooButWithAnother: (PrivateClass *)another;
// what am I to do?
// return another.mineAlone % 3;
// won't work and


But another->mineAlone will.


// return [another mineAlone] % 3;
// would de facto make it public


See above.


}

@end


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: Core Animation

2009-01-23 Thread Scott Anguish

Core Animation handles the threading aspects of this automatically.

The introduction should have been clear about it (if not, file a bug  
with what was unclear)



On 23-Jan-09, at 5:20 PM, David Blanton wrote:


I have gone over the CA docs ... a quick read.

I have an iPhone app that uses the accelerometer to move a puck  
around the x,y plane.  It filters out the effect of gravity per the  
sample code.


I would like to animate two background layers, one rotating cw the  
other ccw and use different  CG blends based on the current location  
of the puck.


Do I need to make the animation in a separate thread or does CA  
handle that for me? I.e. I need responsiveness from the  
accelerometer and the visual effect of the rotating backgrounds/

___

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

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

Help/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: Cocoa-dev Digest, Vol 6, Issue 133

2009-01-23 Thread Derek Kuhl
What I'm trying to do is to allow users to create files and add those  
files into a user support folder so that their other files can inherit  
features of that document.  Essentially, I'm trying to allow  
inheritance in my files.


I was trying to adapt the iClass sample code to work in a document- 
based form.  The iClass example works great if you have the file saved  
at runtime, but in documents they aren't saved right away.  I haven't  
been successful in migrating the document from an internal private  
store into the public document store.


I took out the step where I would try to link between two files yet,  
as that would add another kink in the works.


So, what I've done is taken my NSManagedObject class and had it check  
to see if it needed to update after save to have a permanent objectID.


@implementation MyManagedObject
...
- (void)didSave
{
//set core data URI so it can be pulled back up when it is reloaded
...
	[self setRelationshipURI:[[[relationshipObject objectID]  
URIRepresentation] description] ];

[[self managedObjectContext] save:&error] ;
//Causes duplicate entries in the file:
//
//
//
// 
}
...
@end

Andy Finnell's post on multithreading and cocoa seems like a similar  
problem to what I am experiencing, but everything is on the main  
thread.  I decided to set my merge policy to  
NSMergeByPropertyObjectTrumpMergePolicy anyway.


Could it be due to bindings?  I have an NSTreeController and an  
NSArrayController that both manage the objects at a hierarchal and  
flat level.  I ruled that out due to nothing being wrong with the in- 
memory context.


Finally, I tested what happened when I open one of these files, and it  
opens the most recent version of the object  twice.  I can't figure  
out how to stop the duplicates being stored before it is saved.


I hope this is more fine-grained to get some help on this issue.  I'd  
love to get this working and share the solution.


On Jan 22, 2009, at 11:06 PM, Quincey Morris wrote:


On Jan 21, 2009, at 13:15, Derek Kuhl wrote:


I created a document-based core data application and want it to be
able to add external files from a support folder.  I can
successfully set the permanent URIs for the transient relationships
working in memory, but for some reason saving to file never works
properly.  If I tell each object to save the context using save: in
the didSave: method, it will save a duplicate in the file.  If I try
to save the context in the document's document:didSave:contextInfo:
method mentioned in the documentation, it works again but doesn't
save.  Thank you in advance for any information someone has on what
I'm doing wrong.


Did you get any responses to this and/or are you still having a  
problem?


If you're still looking for assistance, you're going to have to spell
things out a bit more clearly. Are the external files persistent
stores you add to the persistent store controller, or are they just
additional files you keep references to as property values? If you
have information in transient properties, why are you expecting those
values to be saved at all? What kind of context are you talking about?
If you mean managed object context, why are you telling objects to
"save" it? Etc.


___

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

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

Help/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 Animation

2009-01-23 Thread David Blanton
Thank you Scott. I will re-read the introduction ... My speed reading  
techniques may have failed me!



On Jan 23, 2009, at 3:26 PM, Scott Anguish wrote:


Core Animation handles the threading aspects of this automatically.

The introduction should have been clear about it (if not, file a  
bug with what was unclear)



On 23-Jan-09, at 5:20 PM, David Blanton wrote:


I have gone over the CA docs ... a quick read.

I have an iPhone app that uses the accelerometer to move a puck  
around the x,y plane.  It filters out the effect of gravity per  
the sample code.


I would like to animate two background layers, one rotating cw the  
other ccw and use different  CG blends based on the current  
location of the puck.


Do I need to make the animation in a separate thread or does CA  
handle that for me? I.e. I need responsiveness from the  
accelerometer and the visual effect of the rotating backgrounds/





David Blanton





___

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

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

Help/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: NSCaledarDate's deprecation

2009-01-23 Thread Keith Duncan
since NSCalendarDate is a subclass of NSDate, using an  
NSCalendarDate method on an NSDate object is perfectly legal at  
compile time


This should raise a compiler warning.

What you mean is that calling an NSDate method on an instance of  
NSCalendarDate is perfectly legal; however calling a method declared  
in a subclass, on an object strongly typed as it's superclass is not  
legal.


Keith
___

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

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

Help/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: sqlite iphone question....

2009-01-23 Thread Keith Duncan

if (sqlite3_open([path UTF8String], &database) == SQLITE_OK)


Don't use UTF8String to get a C string for a file system path, you  
should use -fileSystemRepresentation.


Keith
___

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

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

Help/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: Drag the whole window just by dragging the Image placed on it?

2009-01-23 Thread Brandon Walkin
Use an NSImageView subclass to draw your image. Put this code in the  
subclass:


- (BOOL)mouseDownCanMoveWindow
{
return YES;
}


On 23-Jan-09, at 4:54 AM, Rahulkumar wrote:


Hi All,



I can move a Window i.e. a NSWindow object with the just a simple call
[myWindow setMovableByWindowBackground:TRUE]. This makes window  
movable from
every point I drag my mouse pointer. Now if I place an NSImage  
Object over
the window and try to drag the whole window there by only dragging  
the Image

, it does not works.

Is there is any way to drag the whole window just by dragging the  
Image

placed on it?



Thanks in advance!



Regards,

Rahul



___

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

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

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

This email sent to bwal...@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: Cocoa-dev Digest, Vol 6, Issue 133

2009-01-23 Thread Quincey Morris

On Jan 23, 2009, at 14:27, Derek Kuhl wrote:

I was trying to adapt the iClass sample code to work in a document- 
based form.  The iClass example works great if you have the file  
saved at runtime, but in documents they aren't saved right away.  I  
haven't been successful in migrating the document from an internal  
private store into the public document store.


I haven't played with iClass, or looked at in any detail, but I'll  
offer the following, FWIW:


Assuming that by "if you have the file saved at runtime" you're  
referring to the fact that the standard untitled document you get with  
NSPersistentDocument doesn't have a persistent store until after you  
save it once, then, yes, that can make things difficult. IMO your best  
strategy is to force the document to be named and saved once before  
the user gets to see it.


If this issue is the only reason you needed to change iClass's  
(presumably) working code for replacing the temporary object  
references with permanent ones, then that strategy should pretty much  
take care of the problem (at the the expense of never having any  
"untitled" document windows).


Unfortunately, iClass looks like a rabbit-hole, and your version of it  
is its own rabbit-hole, and it's going to be difficult to find anyone  
who'll jump down those rabbit-holes with you. I think you'll have more  
success getting answers on this list if you can narrow things down  
even further to specific code fragments.



___

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

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

Help/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: Dynamically set UILabel position ?

2009-01-23 Thread Zhao Wang
Andy,

It works! Thank you so much! I appreciate the help! :)

Sincerely,
Zhao Wang

On Fri, Jan 23, 2009 at 5:13 PM, Andy Lee  wrote:

> UILabel inherits from UIView and therefore has a frame property.  Try
> setting the UILabel's frame.
>
> --Andy
>
>
> On Jan 23, 2009, at 4:37 PM, Zhao Wang wrote:
>
>  Hi, Folks,
>>
>> I am new to iphone development. Now I am writing some small application
>> for
>> study..
>>
>> I wonder if there is a way I can dynamically set UILabel Position. for
>> example, based on user's input of the location? (Or dynamically set the
>> position an control which will display some text message, not necessary to
>> be UILabel)
>>
>> Any suggestion? Thanks in advance!
>>
>> Sincerely,
>> Zhao Wang
>> ___
>>
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>>
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/cocoa-dev/aglee%40mac.com
>>
>> This email sent to ag...@mac.com
>>
>
>
___

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

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

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

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


Re: NSCaledarDate's deprecation

2009-01-23 Thread Andy Lee


On Jan 23, 2009, at 2:45 PM, kvic...@pobox.com wrote:


At Thu, 22 Jan 2009 23:13:45 +, Benjamin Dobson wrote:

On 22 Jan 2009, at 22:52:56, kvic...@pobox.com wrote:

in anticipation of the deprecation of NSCaledarDate, i am in the   
process of converting my app to use NSDate and friends. and while   
the process is mostly straightforward and not all that difficult,  
it  is tedious.


when i think i'm done, i'd like to be able to do a fresh build and

> if possible have the compiler tell me any places i might have
missed... these would be places where i used a method of   
NSCalendarDate that i missed with all my text searches.


is there anyway to get the compiler to do this for me?


If you delete all occurrences of NSCalendarDate and what relevant  
code you can see, the compiler will pick up on undefined variables.


i'm not concerned with "lagging" instances of the text  
"NSCalendarDate" as i'm pretty sure i can find and fix all of them.  
i am concerned with missing a call to a method of NSCalendarDate. if  
this were a class of my own, then i would simply remove the .h/.m  
files from my project and the compiler would then tell me of any  
erroneous calls. but i can't do that with cocoa files/classes. and  
since NSCalendarDate is a subclass of NSDate, using an  
NSCalendarDate method on an NSDate object is perfectly legal at  
compile time. and this is what i'd like to catch at compile time,  
especially if i have (erroneously) cast an NSDate object to id in  
the past.


Once you cast to id all bets are off.  Maybe you could try a hack like  
temporarily removing NSCalendarDate.h, but even then there are other  
places where the compiler can't help you, like key paths and  
@selector().  I think if you want to be really, really sure you're  
going to have to grep your code for each of the 20 or so method names  
that are specific to NSCalendarDate and not NSDate.  Maybe you could  
write a script to do it.


--Andy

___

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

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

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

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


Custom view and ViewController

2009-01-23 Thread Emmanuel Pinault

Hi

I have a custom view that is doing the rendering logic but how can the  
view communicate with the Controller owning it?


Do I need to create an outlet in the view to be able to communicate  
with the controller?


Thanks

Emmanuel

___

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

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

Help/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: NSCaledarDate's deprecation

2009-01-23 Thread kvic...@pobox.com

At 6:39 PM -0500 1/23/09, Andy Lee wrote:

On Jan 23, 2009, at 2:45 PM, kvic...@pobox.com wrote:


At Thu, 22 Jan 2009 23:13:45 +, Benjamin Dobson wrote:

On 22 Jan 2009, at 22:52:56, kvic...@pobox.com wrote:

in anticipation of the deprecation of NSCaledarDate, i am in the  
process of converting my app to use NSDate and friends. and while  
the process is mostly straightforward and not all that difficult, 
it  is tedious.


when i think i'm done, i'd like to be able to do a fresh build and

 > if possible have the compiler tell me any places i might have
missed... these would be places where i used a method of  
NSCalendarDate that i missed with all my text searches.


is there anyway to get the compiler to do this for me?


If you delete all occurrences of NSCalendarDate and what relevant 
code you can see, the compiler will pick up on undefined variables.


i'm not concerned with "lagging" instances of the text 
"NSCalendarDate" as i'm pretty sure i can find and fix all of them. 
i am concerned with missing a call to a method of NSCalendarDate. 
if this were a class of my own, then i would simply remove the 
.h/.m files from my project and the compiler would then tell me of 
any erroneous calls. but i can't do that with cocoa files/classes. 
and since NSCalendarDate is a subclass of NSDate, using an 
NSCalendarDate method on an NSDate object is perfectly legal at 
compile time. and this is what i'd like to catch at compile time, 
especially if i have (erroneously) cast an NSDate object to id in 
the past.


Once you cast to id all bets are off.  Maybe you could try a hack 
like temporarily removing NSCalendarDate.h, but even then there are 
other places where the compiler can't help you, like key paths and 
@selector().  I think if you want to be really, really sure you're 
going to have to grep your code for each of the 20 or so method 
names that are specific to NSCalendarDate and not NSDate.  Maybe you 
could write a script to do it.


--Andy


thats what i suspected. thanx for the reply,
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


ibplugin - framework - application

2009-01-23 Thread Richard Humiston
I built an ibplugin and framework for a custom control using the ib  
plugin programming guide documentation.  The plugin works fine.  Shows  
up in the library.  I can drag it to a window, configure with a custom  
inspector, etc.  When I create an Xcode project and use the control in  
a nib file and build the application, everything works as expected.  I  
noticed if I remove the frameworks from library/frameworks, the nib  
file is not abel to load.  If I put the frameworks back in library/ 
frameworks, the app functions again.


I also noticed that the plugin needs the framework in order to  
function in IB.  I would like to incorporate the frameworks into my  
app rather than have it in library/frameworks, but then the plugin  
won't function in IB while I'm building the interface.  It looks like  
most of the posts here are concerned with ibplugins and frameworks as  
they apply to IB.  Is there a solution to this problem?


thank you,

Rich


___

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

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

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

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


Re: Turn autosaving on forever - is it OK?

2009-01-23 Thread Michael Ash
On Fri, Jan 23, 2009 at 2:37 PM, Vitaly Ovchinnikov
 wrote:
> Hello list,
>
> I implemented autosaving via -setAutosavingDelay call of
> NSDocumentController. I placed checkbox that allows to enable or
> disable autosaving in preferences and now think about removing this
> checkbox and leave autosaving enabled forever. Will I have any
> problems in that case? Maybe in some cases it is better to allow user
> to disable autosaving. Please share your experience.

Reasons not to autosave:

- I'm making some temporary changes that I don't want to keep.
- I'm running on a laptop and trying to keep the hard drive spun down.
- Saving is a long, slow process (either because it's a big file or
because it's being saved to a file server running on dialup in Outer
Mongolia) and it's annoying when it interrupts my work.

I'd say if you're going to autosave, go all the way and save the
document after every single change (maybe with some intelligent
coalescing so that you don't, say, write out a whole new file to disk
with every single keystroke). It's going to be confusing to have my
document be dirty after I change it, but magically become clean after
some period of time has passed.

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: Encryption: Simplest method to encrypt a SQLite DB file...? {iPhone}

2009-01-23 Thread Michael Ash
On Fri, Jan 23, 2009 at 11:41 AM,   wrote:
> Environment: iPhone
>
> I'm particularly concerned with 'data viewing'.
> Think of the data as answers to a quiz.   I worry that some
> hacker could copy & distribute the data (rules) on the internet, and in 
> essence,
> cheat  the game.
>
> Being that "... iPhone is far more restrictive towards tampering...",
> Is it still possible to grab the SQLite DB file from the bundle to view its 
> (uncoded) data?
> If not, then there's no need to encrypt the SQLite DB file within the App 
> Bundle.

To restate what I said in my earlier post: what you want cannot be
done. Your application has encoded within it everything a hacker needs
to know to decode your data. A smart hacker won't even try to decrypt
the data. He'll just run your app in a debugger, let it decrypt the
data itself, and then read it out of memory. Piece of cake.

And yes, this applies to the iPhone just as much as it does anywhere
else, as long as the hacker has jailbroken it first.

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


Questions about the Pantomime framework

2009-01-23 Thread Timothy Standing
I see from searching the archives that there are a small number of  
Cocoa developers who are using or have used Pantomime.


I am in the middle of adding it to the next version of SoftRAID,  
version 4.0 so I can send out email notifications.  I have it mostly  
working (with the exception of SSL support).  Does any one else have  
SSL working reliably?  What version of the framework are you using?   
Is there anyone actively working on this framework or is everyone just  
downloading it and fixing the bugs they encounter individually.


I found that I couldn't send out email on PowerPC using the 1.2.0pre3  
release on the collaberation-world.com Pantomime page but could do it  
using the nightly build dated 08.09.24.  Neither of them seem to work  
with SSL (in my hands).  Our beta testers have also encountered some  
mail servers it doesn't seem to work with at all.


I'm just hoping to avoid working on bugs which others have already  
fixed or working on a version which others know to be unreliable.


Thanks in advance,

Tim Standing
SoftRAID, LLC

___

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

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

Help/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: Turn autosaving on forever - is it OK?

2009-01-23 Thread Vitaly Ovchinnikov
Michael, cocoa's embedded autosaving saves to separate file and leave
the main document dirty. It helps only in case of power lost or
software hang. But as it runs in background, some conflicts are
possible. That's what I wanted to know.

On Sat, Jan 24, 2009 at 5:13 AM, Michael Ash  wrote:
> On Fri, Jan 23, 2009 at 2:37 PM, Vitaly Ovchinnikov
>  wrote:
>> Hello list,
>>
>> I implemented autosaving via -setAutosavingDelay call of
>> NSDocumentController. I placed checkbox that allows to enable or
>> disable autosaving in preferences and now think about removing this
>> checkbox and leave autosaving enabled forever. Will I have any
>> problems in that case? Maybe in some cases it is better to allow user
>> to disable autosaving. Please share your experience.
>
> Reasons not to autosave:
>
> - I'm making some temporary changes that I don't want to keep.
> - I'm running on a laptop and trying to keep the hard drive spun down.
> - Saving is a long, slow process (either because it's a big file or
> because it's being saved to a file server running on dialup in Outer
> Mongolia) and it's annoying when it interrupts my work.
>
> I'd say if you're going to autosave, go all the way and save the
> document after every single change (maybe with some intelligent
> coalescing so that you don't, say, write out a whole new file to disk
> with every single keystroke). It's going to be confusing to have my
> document be dirty after I change it, but magically become clean after
> some period of time has passed.
>
> 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/vitaly.ovchinnikov%40gmail.com
>
> This email sent to vitaly.ovchinni...@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


Knowing when a NSArrayController is ready

2009-01-23 Thread David LeBer
This may be a stupid question, but I've had reason to wonder a number  
of times.


If I have an NSArrayController in a nib, bound to a MOC, configured  
with an Entity name and set to prepare content:


Is there a way to be notified when it has finished loading and  
arranging it's objects?



;david

--
David LeBer
Codeferous Software
'co-def-er-ous' adj. Literally 'code-bearing'
site:   http://codeferous.com
blog:   http://davidleber.net
profile:http://www.linkedin.com/in/davidleber
twitter:http://twitter.com/rebeld
--
Toronto Area Cocoa / WebObjects developers group:
http://tacow.org
___

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

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

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

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


Re: Questions about the Pantomime framework

2009-01-23 Thread Torsten Curdt
> I am in the middle of adding it to the next version of SoftRAID, version 4.0
> so I can send out email notifications.  I have it mostly working (with the
> exception of SSL support).  Does any one else have SSL working reliably?

I did get it working with SSL ...but I switched to (the new) EdMessage
after I had some nasty problems with Pantomime.

No problems since then. Not looking back.

You can find a patched version of EdMessage that works with 10.4 and 10.5 here

http://github.com/tcurdt/edmessage/tree/master

cheers
--
Torsten
___

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

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

Help/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: Using the security framework

2009-01-23 Thread Joe Turner
Okay, so, it seems everyone was right :) I went to cocoabuilder to  
find some of the responses to this, that I never got.


Anyways, it seems I can just call AEWP() once, and it should stay suid.

So, my last question to everyone is, how do I know if the tool is  
suid. I mean, I could implement some sort of lock-unlock thing, and  
then I would be pretty sure, but is there anyway to know for sure?


And, is there a way to take SUID away from it? So, if I want to lock  
it, it would work.


Thanks everyone!

Cheers,

Joe Turner
On Jan 22, 2009, at 4:57 PM, Nick Zitzmann wrote:



On Jan 22, 2009, at 4:09 PM, Joe Turner wrote:

I see. Then, how would you suggest to create a cloner/deleter, if  
it needs root privileges, but cannot use the security framework?


I didn't say you couldn't use the security framework. I said you  
ought to consider re-thinking your strategy.


And, since running scripts from root is dangerous, then is there  
any good way to be able to delete protected (not your user account)  
files? Or, should I just have it copy or delete files the user has  
access to?



There's nothing wrong with running scripts strictly as root, since a  
lot of system scripts are run this way. But AEWP() doesn't run  
executables as root; it runs them as the user with root privileges.  
There's an important difference.


Instead of running a shell script, run another non-GUI command line  
tool of your making with AEWP() that does the required privileged  
task(s). Running shell code with root privileges as some user is  
possible, but it's an easy attack vector due to the inheritance of  
the user's shell environment. Running a command line tool is a bit  
more difficult to hack (but still possible if someone is determined  
enough). Plus, then you can use NSFileManager. :)


You could even take security to the extreme, as I once did in an  
application, and check signatures before calling AEWP(), but that's  
probably too extreme, as it's unlikely someone will rewrite or  
replace your executable unless the file system gave them permission  
to do so.


Nick Zitzmann






___

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

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

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

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


Re: NSCaledarDate's deprecation

2009-01-23 Thread Sean McBride
kvic...@pobox.com (kvic...@pobox.com) on 2009-01-22 5:52 PM said:

>in anticipation of the deprecation of NSCaledarDate, i am in the
>process of converting my app to use NSDate and friends. and while the
>process is mostly straightforward and not all that difficult, it is
>tedious.
>
>when i think i'm done, i'd like to be able to do a fresh build and if
>possible have the compiler tell me any places i might have missed...
>these would be places where i used a method of NSCalendarDate that i
>missed with all my text searches.

Take a look at the declaration of NSString.h's cString method.  Maybe
you could hack NSCalendarDate.h and add DEPRECATED_ATTRIBUTE where desired.

Sean


___

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

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

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

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


iPhone Vibrate

2009-01-23 Thread David Blanton

I want to be sensitive to battery usage in the iPhone.

When calling

AudioServicesPlayAlertSound ( kSystemSoundID_Vibrate  );

How much battery does this use?  I may be calling this 'alot' in my  
application.





David Blanton





___

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

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

Help/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: firewall api

2009-01-23 Thread Chris Benedict


On Jan 23, 2009, at 2:13 AM, Andrew Farmer wrote:


On 22 Jan 09, at 14:38, Chris Benedict wrote:
First, I'm pretty new to Mac OS X programming so please bear with  
my ignorance.


I was hoping to get a bit of quick advice.  I'm wanting to write a  
little application that will kind of put my MacBook in a lock down  
mode of sorts.  It would need to block/ignore all network traffic  
except for an app or two when you hit a button and then deactivate  
when you hit another button to return to the original settings.


My question is whether or not there is a public API to interact  
with the built-in firewall on Mac OS X 10.5 or if I would need to  
interface with system preferences somehow and just setup the  
firewall to block all connections except for the one app that I  
want to allow through or if there is a completely different way to  
go about doing this.  I found a program called Little Snitch which  
seems similar but way overkill for what I want to do and at first  
glance it looks like they do things with the drivers or something  
like that which honestly is above my head.


The built-in firewall is ipfw - the implementation on OS X is  
largely identical to the implementation in FreeBSD, so there's  
plenty of documentation online. I'm not aware of any specific API  
provided by Apple for managing the firewall, but the ipfw tool is  
probably good enough. Note that you'll need root privileges to use it.


The limit you're going to run into trying to write a tool like this  
is that you can't apply packet filters on a per-application level.  
The closest you can get is blocking packets which are addressed to  
specific ports, or which are destined for processes owned by  
specific users. Little Snitch accomplishes finer-grained  
restrictions by implementing a kernel extension; I do *NOT*  
recommend taking this approach unless you have a lot of spare time,  
and don't mind debugging kernel panics.


Thanks, I was hoping it would be that easy.  I'm assuming that Apple  
implements the per-application access simply by detecting which  
port[s] an application wants to bind to and then allowing access to  
those ports?  Or is it more involved than that?  I ask purely out of  
curiosity because the application I'm wanting to allow to pass through  
uses static ports so I hopefully won't need to do 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


Poof! Recently-saved Core Data document suddenly gets dirty

2009-01-23 Thread Jerry Krinock
In my Core Data Document-Based application, I have a menu item which  
imports settings from a legacy application.  For each setting found,  
it programatically creates a new document, saves it, and leaves the  
new document window open.  When all done, the user gets a modal dialog  
showing a list of what was imported.


This works fine, except when importing some setting datasets,  
sometimes, after the modal dialog has been displayed, often 2 seconds  
later -- poof -- the created document receives an updateChangeCount:  
message, and in its window, the 'close' button becomes dirty.  During  
other program runs with the same data, this does not happen until  
after I dismisses the modal dialog.  Very weird.  In either case, my  
observer of NSManagedObjectContextObjectsDidChangeNotification does  
^not^ receive any notification when the document gets dirtied.  What  
could dirty the document without triggering this notification?


To investigate, I saved the dirty document with a new name, thinking  
that whatever changed would be different between the two xml files.   
One of my entities has an attribute which is a transformable  
("encodable") dictionary of a few short strings.  The only significant  
difference I see between the two files is that, for one of my objects,  
the base64 representation of these dictionaries is different.  Re- 
reading both documents into my app with some extra logging however,  
they both decode to exactly the same key/value pairs.


Examining the xml more closely with BBEdit, in one test I found the  
two encoded dictionaries to be just slightly different, both  
containing exactly 621 base64 characters, but there were two blocks of  
four characters that occur in different locations, and, near the end,  
four characters were different. In another test, the differences were  
more substantial -- character counts were 525 vs 641, and maybe half  
of the characters were different.


Apparently, encoding of these dictionaries is non-deterministic, so I  
modified my "supersetters" (methods that set key/value pairs within  
these dictionaries) to make sure that the actual dictionary setter is  
only invoked if there is a genuine difference between the new and old  
values.  [1]  But that did not help, and indeed an NSLog placed in an  
"else" branch of this condition, indicating an attempt to re-set a key  
to the same value, never runs.


I over-rode updateChangeCount: and put a breakpoint in there.  The  
call stack is shown below [2].  Are there any clues in there as to  
what is triggering this extraneous updateChangeCount:?


During the import, some transient properties are set and gotten, but  
this is all complete before the document is saved.


I realize I could probably paper over this problem by disabling undo  
registration during the import, or by sending - 
updateChangeCount:NSChangeCleared when I dismiss my dialog.  But I'm  
worried about not knowing the cause of the weird behavior before I  
ship this thing.


Thanks for reading,

Jerry Krinock

[1]  At any rate, this might cause extraneous undo registrations.   
I've noticed more than once when using others' Core Data apps that I  
sometimes need to click "Undo" seven or eight times times before  
anything happens  :|


[2]  Call Stack for the extraneous updateChangeCount:.  In #0,  
Bookshelf is my NSPersistentDocument subclass.  All the other  
functions are Apple's except for #53, #54 and #55.


#0  0x0003dfdc in -[Bookshelf updateChangeCount:] at Bookshelf.m:1344
#1  0x91fd8e1a in _nsnote_callback
#2  0x9702f8da in __CFXNotificationPost
#3  0x9702fbb3 in _CFXNotificationPostNotification
#4	0x91fd6080 in -[NSNotificationCenter  
postNotificationName:object:userInfo:]

#5  0x91fdf8c8 in -[NSNotificationCenter postNotificationName:object:]
#6  0x9203fc58 in -[NSUndoManager endUndoGrouping]
#7  0x970d6a4c in -[NSSet makeObjectsPerformSelector:withObject:]
#8	0x9201e390 in +[NSUndoManager(NSUndoManagerPrivate)  
_endTopLevelGroupings]

#9  0x90eecefb in NSMenuItemCarbonEventHandler
#10 0x933121e3 in HIObject::Construct
#11 0x93311ad6 in HIObject::Create
#12 0x93311a06 in HIObjectCreate
#13 0x933500f4 in _HIMenuGetItemView
#14 0x9334fecf in HIMenuGetItemView
#15 0x93551864 in MenuData::ShouldReturnItemViewAsChild
#16 0x93552247 in MenuData::HandleGetAccessibleChildren
#17 0x93553a1c in MenuData::ContentViewGetNamedAccessibleAttribute
#18 0x9339a172 in HIObject::DispatchAccessibilityEvent
#19 0x93551913 in MenuData::MenuContentViewAccessibilityHandler
#20 0x93317143 in DispatchEventToHandlers
#21 0x9331657d in SendEventToEventTargetInternal
#22 0x933163e2 in SendEventToEventTargetWithOptions
#23 0x934ad808 in Accessible::SendEvent
#24 0x934aea5e in Accessible::GetNamedAttributeData
#25 0x934aecaa in HLTBCopyUIElementAttributeValue
#26 0x935522c8 in MenuData::GetAccessibleChildrenSelf
#27 0x9339ab4f in HIObjec

Re: firewall api

2009-01-23 Thread Thomas Davie


On 24 Jan 2009, at 07:26, Chris Benedict wrote:



On Jan 23, 2009, at 2:13 AM, Andrew Farmer wrote:


On 22 Jan 09, at 14:38, Chris Benedict wrote:
First, I'm pretty new to Mac OS X programming so please bear with  
my ignorance.


I was hoping to get a bit of quick advice.  I'm wanting to write a  
little application that will kind of put my MacBook in a lock down  
mode of sorts.  It would need to block/ignore all network traffic  
except for an app or two when you hit a button and then deactivate  
when you hit another button to return to the original settings.


My question is whether or not there is a public API to interact  
with the built-in firewall on Mac OS X 10.5 or if I would need to  
interface with system preferences somehow and just setup the  
firewall to block all connections except for the one app that I  
want to allow through or if there is a completely different way to  
go about doing this.  I found a program called Little Snitch which  
seems similar but way overkill for what I want to do and at first  
glance it looks like they do things with the drivers or something  
like that which honestly is above my head.


The built-in firewall is ipfw - the implementation on OS X is  
largely identical to the implementation in FreeBSD, so there's  
plenty of documentation online. I'm not aware of any specific API  
provided by Apple for managing the firewall, but the ipfw tool is  
probably good enough. Note that you'll need root privileges to use  
it.


The limit you're going to run into trying to write a tool like this  
is that you can't apply packet filters on a per-application level.  
The closest you can get is blocking packets which are addressed to  
specific ports, or which are destined for processes owned by  
specific users. Little Snitch accomplishes finer-grained  
restrictions by implementing a kernel extension; I do *NOT*  
recommend taking this approach unless you have a lot of spare time,  
and don't mind debugging kernel panics.


Thanks, I was hoping it would be that easy.  I'm assuming that Apple  
implements the per-application access simply by detecting which  
port[s] an application wants to bind to and then allowing access to  
those ports?  Or is it more involved than that?  I ask purely out of  
curiosity because the application I'm wanting to allow to pass  
through uses static ports so I hopefully won't need to do that.


Uh, not that I have a useful answer to this question, but since  
leopard, the built in firewall has not been ipfw, it's been apple's  
custom application firewall.  While ipfw is still useable, it's  
certainly not the built in one.


Bob
___

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

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

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

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