Re: Tell which type is in NSValue?

2009-08-05 Thread Bill Bumgarner

On Aug 4, 2009, at 11:38 PM, aaron smith wrote:


if I receive an NSValue object, how can I find out if the value it
contains is a point/rect/size/ etc. I can't figure out what to compare
it with, and can't figure out if the objCType is something I can use
for that problem. Any ideas?


This:

http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/nsvalue_Class/Reference/Reference.html#//apple_ref/occ/instm/NSValue/objCType

Implies this:

http://developer.apple.com/documentation/Cocoa/Conceptual/NumbersandValues/Articles/Values.html#//apple_ref/doc/uid/2174-BAJJHDEG

Which implies this:

http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtTypeEncodings.html

b.bum



___

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

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

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

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


Re: Tell which type is in NSValue?

2009-08-05 Thread aaron smith
thanks for the info. I'm trying to put it all together. help me out?

I've tried a couple diff things, here's what Im trying..

NSPoint thePoint2 = NSMakePoint(30.0,35.0);
//NSValue *test = [NSValue valueWithBytes:&thePoint2 objCType:@encode(NSPoint)];
NSValue *test = [NSValue valueWithPoint:thePoint2];
if([test objCType] == @encode(NSPoint)) printf("test is an NSPoint");

thanks a bunch




On Tue, Aug 4, 2009 at 11:59 PM, Bill Bumgarner wrote:
> On Aug 4, 2009, at 11:38 PM, aaron smith wrote:
>
>> if I receive an NSValue object, how can I find out if the value it
>> contains is a point/rect/size/ etc. I can't figure out what to compare
>> it with, and can't figure out if the objCType is something I can use
>> for that problem. Any ideas?
>
> This:
>
> http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/nsvalue_Class/Reference/Reference.html#//apple_ref/occ/instm/NSValue/objCType
>
> Implies this:
>
> http://developer.apple.com/documentation/Cocoa/Conceptual/NumbersandValues/Articles/Values.html#//apple_ref/doc/uid/2174-BAJJHDEG
>
> Which implies this:
>
> http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtTypeEncodings.html
>
> b.bum
>
>
>
>
___

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

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

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

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


Re: Tell which type is in NSValue?

2009-08-05 Thread aaron smith
ah. I got it. Here's what I did. this seems like the slickets or
standard way to go:

NSPoint thePoint2 = NSMakePoint(30.0,35.0);
NSValue *test = [NSValue valueWithBytes:&thePoint2 objCType:@encode(NSPoint)];
if(strcmp((const char *)[test objCType],(const char *)@encode(NSPoint))==0) {
}

On Wed, Aug 5, 2009 at 1:15 AM, aaron
smith wrote:
> thanks for the info. I'm trying to put it all together. help me out?
>
> I've tried a couple diff things, here's what Im trying..
>
> NSPoint thePoint2 = NSMakePoint(30.0,35.0);
> //NSValue *test = [NSValue valueWithBytes:&thePoint2 
> objCType:@encode(NSPoint)];
> NSValue *test = [NSValue valueWithPoint:thePoint2];
> if([test objCType] == @encode(NSPoint)) printf("test is an NSPoint");
>
> thanks a bunch
>
>
>
>
> On Tue, Aug 4, 2009 at 11:59 PM, Bill Bumgarner wrote:
>> On Aug 4, 2009, at 11:38 PM, aaron smith wrote:
>>
>>> if I receive an NSValue object, how can I find out if the value it
>>> contains is a point/rect/size/ etc. I can't figure out what to compare
>>> it with, and can't figure out if the objCType is something I can use
>>> for that problem. Any ideas?
>>
>> This:
>>
>> http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/nsvalue_Class/Reference/Reference.html#//apple_ref/occ/instm/NSValue/objCType
>>
>> Implies this:
>>
>> http://developer.apple.com/documentation/Cocoa/Conceptual/NumbersandValues/Articles/Values.html#//apple_ref/doc/uid/2174-BAJJHDEG
>>
>> Which implies this:
>>
>> http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtTypeEncodings.html
>>
>> b.bum
>>
>>
>>
>>
>
___

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

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

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

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


Re: Tell which type is in NSValue?

2009-08-05 Thread Alastair Houghton

On 5 Aug 2009, at 09:15, aaron smith wrote:


thanks for the info. I'm trying to put it all together. help me out?

I've tried a couple diff things, here's what Im trying..

if([test objCType] == @encode(NSPoint)) printf("test is an NSPoint");


AFAIK @encode(), unlike @selector(), doesn't try to make the string it  
returns unique.  So I'm guessing you aren't seeing your "test is an  
NSPoint" message?  (You don't say...)


You probably want

  if (strcmp ([test objCType], @encode(NSPoint)) == 0)
printf ("test is an NSPoint");

or similar.

Make sure you read the type encodings docs, because there are some  
gotchas; for instance, typedefs have no representation in the type  
encoding, so two structures whose members' *base types* are equal will  
have the same type encoding.


Usually when you're using NSValue, you already know what type you're  
dealing with.  If you have a situation where you need to distinguish  
between several different things, you might be better off making some  
wrapper classes (or maybe subclasses of NSValue, which is how NSNumber  
works).


Kind regards,

Alastair.

--
http://alastairs-place.net



___

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

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

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

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


Re: Main Event queue

2009-08-05 Thread Ken Thomases

On Aug 4, 2009, at 7:10 PM, Sandro Noel wrote:

Is there a cocoa or carbon framework that would allow my software to  
hook onto the system main event queue, like in windows?

or to hook into the window manager.

I would like to peek at every message that traverse the main queue.


Do you mean just your own application's event queue or all on the  
system?  Event taps are fine for either, but perhaps at too low a  
level or too broad a scope.  If you only want to monitor the events of  
your own application, you might consider subclassing NSApplication and  
overriding -sendEvent:.  That will be limited, however, to the main  
event loop.  Modal event loops implemented around - 
nextEventMatchingMask:... methods don't necessarily pass events  
through -[NSApplication sendEvent:].


Regards,
Ken

___

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

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

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

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


Generating random numbers

2009-08-05 Thread Mahaboob
I need to produce 15 random numbers between 1 to 16 without repeating any
number. I used the code like

int i,j;
for(i=0;i<15;i++){
j =random() % 15 +1;
NSLog(@"No: %d => %d \n",i,j);
srandom(time(NULL)+i);
}
But some numbers are repeating.
How can I do it without repeating the numbers?

Thanks in advance
Mahaboob


___

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

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

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

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


Re: Generating random numbers

2009-08-05 Thread I. Savant

On Aug 5, 2009, at 6:44 AM, Mahaboob wrote:

I need to produce 15 random numbers between 1 to 16 without  
repeating any

number.

...

How can I do it without repeating the numbers?



  Here, try this:

  http://tinyurl.com/lo6tp4

--
I.S.




___

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

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

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

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


Re: Generating random numbers

2009-08-05 Thread Ken Thomases

On Aug 5, 2009, at 5:44 AM, Mahaboob wrote:

I need to produce 15 random numbers between 1 to 16 without  
repeating any

number. I used the code like

   int i,j;
   for(i=0;i<15;i++){
   j =random() % 15 +1;
   NSLog(@"No: %d => %d \n",i,j);
   srandom(time(NULL)+i);
   }
But some numbers are repeating.
How can I do it without repeating the numbers?


Hmm.  When using random number generators, you typically do not seed  
the generator repeatedly.  You seed it once and then have it generate  
numbers repeatedly.


Next, "random() % 15 + 1" will give values from 1 to 15, not 1 to 16.

Lastly, random number sequences may repeat.  That's an inherent  
property of randomness.


What you really want is known as a shuffle.  You want the numbers from  
1 to 15 (or is it 16?) shuffled into a random order.  http://en.wikipedia.org/wiki/Shuffling#Shuffling_algorithms


Regards,
Ken

___

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

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

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

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


Re: Generating random numbers

2009-08-05 Thread Citizen

On 5 Aug 2009, at 11:44, Mahaboob wrote:

I need to produce 15 random numbers between 1 to 16 without  
repeating any

number. I used the code like

   int i,j;
   for(i=0;i<15;i++){
   j =random() % 15 +1;
   NSLog(@"No: %d => %d \n",i,j);
   srandom(time(NULL)+i);
   }
But some numbers are repeating.
How can I do it without repeating the numbers?



This isn't really a Cocoa question.

One solution is to add each item to an array. Add an inner loop that  
loops through that array each time you generate a new random number to  
see if it is already been used, if not then print it - and add it to  
the array.


This is probably not the most efficient solution, but should work well  
for your requirements.


srandom should probably be called outside your loop. There is no point  
initializing the random number generator multiple times like this.


Hope that helps.
Dave

--
David Kennedy (http://www.zenopolis.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: Tell which type is in NSValue?

2009-08-05 Thread Graham Cox


On 05/08/2009, at 6:27 PM, Alastair Houghton wrote:

Usually when you're using NSValue, you already know what type you're  
dealing with.  If you have a situation where you need to distinguish  
between several different things, you might be better off making  
some wrapper classes (or maybe subclasses of NSValue, which is how  
NSNumber works).



Not only that, but note this from the docs for [NSNumber objCType]:  
"Special Considerations The returned type does not necessarily match  
the method the receiver was created with."


This makes it very hard to preserve type information using NSNumbers -  
integers and floats usually end up converted internally to doubles, I  
found. The same warning does not appear to be applied to NSValue  
however. If type is of critical importance though, I'd store it  
explicitly in an object of your own devising.


--Graham


___

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

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

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

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


Re: Generating random numbers

2009-08-05 Thread Graham Cox


On 05/08/2009, at 8:44 PM, Mahaboob wrote:

I need to produce 15 random numbers between 1 to 16 without  
repeating any

number. I used the code like

   int i,j;
   for(i=0;i<15;i++){
   j =random() % 15 +1;
   NSLog(@"No: %d => %d \n",i,j);
   srandom(time(NULL)+i);
   }
But some numbers are repeating.
How can I do it without repeating the numbers?



A truly random number may be repeated. If it's guaranteed not to, it's  
not random.


Maybe you're really just trying to randomly order a number of objects?  
One way to do that is to assign a random number to each object and  
sort the list on the random number.


--Graham


___

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

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

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

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


Re: Main Event queue

2009-08-05 Thread Sandro Noel

Dave, Ken thank you very much for the information.

what I would like to do is broad range, get information about every  
action for every application in my current desktop session.


Window movement, hide, show, activate, deactivate, open, close, mouse  
movement, drag and drop operations, contextual menus pop-up.

I want to know everything.

Raw mouse movements, or mouse clicks are of little interest, so are  
keyboard events.
What i am interested in is the action happening after a mouse movement  
or click, or keyboard shortcuts, menu selections has happened.

anything that influences display of content on the desktop.


This subject is still in research mode for me so please excuse me if  
it seems like i don't know what I'm talking about
I'm trying to find out what can actually be done, so it's kind of hard  
to use the right terminology.


thank you very much for your help it's greatly appreciated.

Sandro Noël
sandro.n...@mac.com
Mac OS X : Swear by your computer, not at it.

P
-Pensez vert! avant d’imprimer ce courriel.
-Go Green! please consider the environment before printing this email.




On 5-Aug-09, at 5:24 AM, Ken Thomases wrote:

On Aug 4, 2009, at 7:10 PM, Sandro Noel wrote:

Is there a cocoa or carbon framework that would allow my software to  
hook onto the system main event queue, like in windows?

or to hook into the window manager.

I would like to peek at every message that traverse the main queue.


Do you mean just your own application's event queue or all on the  
system?  Event taps are fine for either, but perhaps at too low a  
level or too broad a scope.  If you only want to monitor the events of  
your own application, you might consider subclassing NSApplication and  
overriding -sendEvent:.  That will be limited, however, to the main  
event loop.  Modal event loops implemented around - 
nextEventMatchingMask:... methods don't necessarily pass events  
through -[NSApplication sendEvent:].


Regards,
Ken


___

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

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

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

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


Re: Main Event queue

2009-08-05 Thread Ken Thomases

On Aug 5, 2009, at 9:50 AM, Sandro Noel wrote:

what I would like to do is broad range, get information about every  
action for every application in my current desktop session.


Window movement, hide, show, activate, deactivate, open, close,  
mouse movement, drag and drop operations, contextual menus pop-up.

I want to know everything.

Raw mouse movements, or mouse clicks are of little interest, so are  
keyboard events.
What i am interested in is the action happening after a mouse  
movement or click, or keyboard shortcuts, menu selections has  
happened.

anything that influences display of content on the desktop.


Hmm, I don't think you can quite achieve that.

Event taps can only give you the low-level events like mouse clicks  
and key presses.


The individual frameworks (Carbon and Cocoa) are responsible for  
interpreting those events into the higher-level behaviors you're  
talking about.  And that generally occurs inside of individual  
application processes, not centrally in the window server where event  
taps operate.


You might look into the Accessibility API.  That can probably give a  
richer description of what's happening, although perhaps not as rich  
as you're hoping.


Regards,
Ken

___

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

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

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

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


Re: Core Data completely unable to find the source object model for migration

2009-08-05 Thread mmalc Crawford


On Aug 4, 2009, at 11:20 PM, Matteo Manferdini wrote:


I created a mapping model and
called addPersistentStoreWithType:configuration:URL:options:error:
with the NSMigratePersistentStoresAutomaticallyOption option.


Did you create a mapping model?
If not, did you specify the NSInferMappingModelAutomaticallyOption  
option?


NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES],  
NSMigratePersistentStoresAutomaticallyOption,
[NSNumber numberWithBool:YES],  
NSInferMappingModelAutomaticallyOption, nil];


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: Main Event queue

2009-08-05 Thread David Blanton
You need to do remote debugging, you can look up how to accomplish  
this, I did it some years ago and don't remember.


Look at the Cocoa and Carbon APIs and make educated guesses as to what  
would  be called when for example, a contextual menu is to be displayed.


Set a break point on that API.

Perform the action on the target machine and see if it hits.  If not  
make another guess.  You will be surprised how quickly you can home in  
on correct API.



I did this years ago building a DRM KEXT and could trap, in one  
example all print operations from all applications.


Good luck!

db







On Aug 5, 2009, at 9:42 AM, Ken Thomases wrote:


On Aug 5, 2009, at 9:50 AM, Sandro Noel wrote:

what I would like to do is broad range, get information about every  
action for every application in my current desktop session.


Window movement, hide, show, activate, deactivate, open, close,  
mouse movement, drag and drop operations, contextual menus pop-up.

I want to know everything.

Raw mouse movements, or mouse clicks are of little interest, so are  
keyboard events.
What i am interested in is the action happening after a mouse  
movement or click, or keyboard shortcuts, menu selections has  
happened.

anything that influences display of content on the desktop.


Hmm, I don't think you can quite achieve that.

Event taps can only give you the low-level events like mouse clicks  
and key presses.


The individual frameworks (Carbon and Cocoa) are responsible for  
interpreting those events into the higher-level behaviors you're  
talking about.  And that generally occurs inside of individual  
application processes, not centrally in the window server where  
event taps operate.


You might look into the Accessibility API.  That can probably give a  
richer description of what's happening, although perhaps not as rich  
as you're hoping.


Regards,
Ken

___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/airedale%40tularosa.net

This email sent to aired...@tularosa.net




___

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

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

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

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


Re: Generating random numbers

2009-08-05 Thread Agha Khan

Dear Mahaboob:
Many people have answered this question but I will take this route.

First of all you only have call srandom once in you program. Best  
place is when you are going to load the object.


I defined 2 macros

#define RANDOM_SEED() srandom(time(NULL))
#define RANDOM_INT(__MIN__, __MAX__) ((__MIN__) + random() % ((__MAX__ 
+1) - (__MIN__)))


#define ARRAYSIZE 15

Now I assume that you already called RANDOM_SEDD previously.
Now create an array with your range of your numbers. In your case 1 to  
16.


int RandArray[ARRAYSIZE];

for (int i = 0; i < ARRAYSIZE; i++)
{
RandArray[i] = i + 1; // choose your own range
}

Now shuffle them

for (int i = 0; i < ARRAYSIZE; i++)
{
int RandomNumber = RANDOM_INT(0, ARRAYSIZE);
  int temp = RandArray[RandomNumber];
  RandArray[RandomNumber] = RandArray[i];
  RandArray[i] = temp
}

:-)
Agha

On Aug 5, 2009, at 3:44 AM, Mahaboob wrote:

I need to produce 15 random numbers between 1 to 16 without  
repeating any

number. I used the code like

   int i,j;
   for(i=0;i<15;i++){
   j =random() % 15 +1;
   NSLog(@"No: %d => %d \n",i,j);
   srandom(time(NULL)+i);
   }
But some numbers are repeating.
How can I do it without repeating the numbers?

Thanks in advance
Mahaboob


___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/agha.khan%40me.com

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


How can we distinguish which alert we are talking about?

2009-08-05 Thread Agha Khan

Hi:
I need 2 alerts in my class
Code taken from (the iPhone Developer's Cookbook) and works fine with  
if you have only one alert.
When user presses Ok/Cancel button it (void)alertView:(UIAlertView  
*)alertView activates function.





- (void) presentSheet
{
UIAlertView *alert = [[UIAlertView alloc]
  initWithTitle: @"Enter 
Information"
  message:@"Specify the Name and 
URL"
  delegate:self
  cancelButtonTitle:@"Cancel"
  otherButtonTitles:@"OK", nil];

[alert show];
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex: 
(NSInteger)buttonIndex

{
printf("User Pressed Button %d\n", buttonIndex + 1);
	printf("Text Field 1: %s\n", [[[alertView textFieldAtIndex:0] text]  
cStringUsingEncoding:1]);
	printf("Text Field 2: %s\n", [[[alertView textFieldAtIndex:1] text]  
cStringUsingEncoding:1]);	

[alertView release];
}

Now I have another alert in same file.

- (void) presentSheet2
{
UIAlertView *alert = [[UIAlertView alloc]
  initWithTitle: @"need 
Information"
  message:@"Have you heard from 
Apple"
  delegate:self
  cancelButtonTitle:@"No"
  otherButtonTitles:@"Yes", 
nil];

[alert show];
}


How can we distinguish which alert we are talking about?
Thanks in advance.

Agha

___

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

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

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

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


Re: How can we distinguish which alert we are talking about?

2009-08-05 Thread Chase Meadors

In your delegate, method, do this:

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex: 
(NSInteger)buttonIndex {


if ([[alertView title] isEqualToString:@"Some Title"]) {

...
return;

} if ([[alertView title] isEqualToString:@"Some Other Title"]) {

...
return;

}

}

Feel free to judge based on any other property as well, although title  
is the simplest and shortest.


On Aug 5, 2009, at 1:08 PM, Agha Khan wrote:


Hi:
I need 2 alerts in my class
Code taken from (the iPhone Developer's Cookbook) and works fine  
with if you have only one alert.
When user presses Ok/Cancel button it (void)alertView:(UIAlertView  
*)alertView activates function.





- (void) presentSheet
{
UIAlertView *alert = [[UIAlertView alloc]
  initWithTitle: @"Enter 
Information"
  message:@"Specify the Name and 
URL"
  delegate:self
  cancelButtonTitle:@"Cancel"
  otherButtonTitles:@"OK", nil];

[alert show];
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex: 
(NSInteger)buttonIndex

{
printf("User Pressed Button %d\n", buttonIndex + 1);
	printf("Text Field 1: %s\n", [[[alertView textFieldAtIndex:0] text]  
cStringUsingEncoding:1]);
	printf("Text Field 2: %s\n", [[[alertView textFieldAtIndex:1] text]  
cStringUsingEncoding:1]);	

[alertView release];
}

Now I have another alert in same file.

- (void) presentSheet2
{
UIAlertView *alert = [[UIAlertView alloc]
  initWithTitle: @"need 
Information"
  message:@"Have you heard from 
Apple"
  delegate:self
  cancelButtonTitle:@"No"
  otherButtonTitles:@"Yes", 
nil];

[alert show];
}


How can we distinguish which alert we are talking about?
Thanks in advance.

Agha

___

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

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

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

This email sent to c.ed.m...@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: How can we distinguish which alert we are talking about?

2009-08-05 Thread Randall Meadows

On Aug 5, 2009, at 12:08 PM, Agha Khan wrote:


Hi:
I need 2 alerts in my class
Code taken from (the iPhone Developer's Cookbook) and works fine  
with if you have only one alert.
When user presses Ok/Cancel button it (void)alertView:(UIAlertView  
*)alertView activates function.


[snip]


Now I have another alert in same file.


[snip]


How can we distinguish which alert we are talking about?
Thanks in advance.


Use the 'tag' property (which UIAlertView inherits from UIView) to  
assign a unique identifier to each one, which you can then use in the  
delegate method to determine which one is active.


UIAlertView *alert = [[UIAlertView alloc...
alert.tag = kSomeCustomTagIdentifier;
[alert show];

Or use the title as a differentiator.

You could also assign each UIAlertView to an ivar, and compare those  
against the "alertView" parameter passed to the delegate method.


Or you could assign them different delegate objects.

___

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

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

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

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


Re: How can we distinguish which alert we are talking about?

2009-08-05 Thread Kyle Sluder
On Wed, Aug 5, 2009 at 11:08 AM, Agha Khan wrote:
> How can we distinguish which alert we are talking about?

You are given the alert as the first argument of the delegate method.
What more could you possibly want?  Stuff it in an ivar and do an
equality check.

--Kyle Sluder
___

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

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

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

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


Re: Main Event queue

2009-08-05 Thread Greg Guerin

Sandro Noel wrote:

what I would like to do is broad range, get information about every  
action for every application in my current desktop session.



Dtrace?

Try google keywords:
  dtrace mac os x

  -- GG

___

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

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

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

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


Re: How can we distinguish which alert we are talking about?

2009-08-05 Thread Kyle Sluder
On Wed, Aug 5, 2009 at 11:16 AM, Chase Meadors wrote:
>        if ([[alertView title] isEqualToString:@"Some Title"]) {

In addition to this being very bad style, I take it you've never
written a localized application?

--Kyle Sluder
___

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

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

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

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


Re: Generating random numbers

2009-08-05 Thread Scott Andrew
This is not a cocoa question and is a basic C question. The simple  
solution is to keep a 2nd array of numbers already generated.


Sent from my iPhone

On Aug 5, 2009, at 3:44 AM, Mahaboob  wrote:

I need to produce 15 random numbers between 1 to 16 without  
repeating any

number. I used the code like

   int i,j;
   for(i=0;i<15;i++){
   j =random() % 15 +1;
   NSLog(@"No: %d => %d \n",i,j);
   srandom(time(NULL)+i);
   }
But some numbers are repeating.
How can I do it without repeating the numbers?

Thanks in advance
Mahaboob


___

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

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

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

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


iPhone: How can I rotate UIImageView without blockiness?

2009-08-05 Thread Eric E. Dolecki
I am making an analog clock, and I have 3 PNGs for the arms. I am rotating
these, but they look awful with blocky edges. The second hand is a pixel
wide for instance. Is there a trick to use smoothing (aliasing) or
something?



Here is the method I call via NSTimer every second. Is there a better way to
this (I don't know OpenGL or anything like that at the moment)? CALayer?


- (void) showActivity {
NSCalendar *gregorian = [[NSCalendar alloc]
initWithCalendarIdentifier:NSGregorianCalendar];
unsigned unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit |
NSDayCalendarUnit | NSHourCalendarUnit| NSMinuteCalendarUnit
|NSSecondCalendarUnit;
NSDate *date = [NSDate date];
 NSDateComponents *comps = [gregorian components:unitFlags fromDate:date];
 int h = [comps hour];
 int m = [comps minute];
 int s = [comps second];

CGAffineTransform cgaRotateHr  =
CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(h * 30));
CGAffineTransform cgaRotateMin =
CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(m * 6));
CGAffineTransform cgaRotateSec =
CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(s * 6));

//Looks awful but it works (PNGs with transparency have blocked edges)
 [hrHand setTransform:cgaRotateHr];
 [minHand setTransform:cgaRotateMin];
 [secondHand setTransform:cgaRotateSec];

NSDateFormatter *formatter = [[[NSDateFormatter alloc] init] autorelease];
 [formatter setTimeStyle:NSDateFormatterMediumStyle];
 [clockLabel setText:[formatter stringFromDate:date]];
}
___

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

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

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

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


Re: How can we distinguish which alert we are talking about?

2009-08-05 Thread Alex Kac

I prefer to use the .tag property and set a constant for them.

On Aug 5, 2009, at 1:16 PM, Chase Meadors wrote:


In your delegate, method, do this:

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex: 
(NSInteger)buttonIndex {


if ([[alertView title] isEqualToString:@"Some Title"]) {

...
return;

} if ([[alertView title] isEqualToString:@"Some Other Title"]) {

...
return;

}

}

Feel free to judge based on any other property as well, although  
title is the simplest and shortest.


On Aug 5, 2009, at 1:08 PM, Agha Khan wrote:


Hi:
I need 2 alerts in my class
Code taken from (the iPhone Developer's Cookbook) and works fine  
with if you have only one alert.
When user presses Ok/Cancel button it (void)alertView:(UIAlertView  
*)alertView activates function.





- (void) presentSheet
{
UIAlertView *alert = [[UIAlertView alloc]
  initWithTitle: @"Enter 
Information"
  message:@"Specify the Name and 
URL"
  delegate:self
  cancelButtonTitle:@"Cancel"
  otherButtonTitles:@"OK", nil];

[alert show];
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex: 
(NSInteger)buttonIndex

{
printf("User Pressed Button %d\n", buttonIndex + 1);
	printf("Text Field 1: %s\n", [[[alertView textFieldAtIndex:0]  
text] cStringUsingEncoding:1]);
	printf("Text Field 2: %s\n", [[[alertView textFieldAtIndex:1]  
text] cStringUsingEncoding:1]);	

[alertView release];
}

Now I have another alert in same file.

- (void) presentSheet2
{
UIAlertView *alert = [[UIAlertView alloc]
  initWithTitle: @"need 
Information"
  message:@"Have you heard from 
Apple"
  delegate:self
  cancelButtonTitle:@"No"
  otherButtonTitles:@"Yes", 
nil];

[alert show];
}


How can we distinguish which alert we are talking about?
Thanks in advance.

Agha

___

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

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

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


This email sent to c.ed.m...@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/alex%40webis.net

This email sent to a...@webis.net


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

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




___

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

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

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

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


[iPhone] Webview stringByEvaluatingJavaScriptFromString

2009-08-05 Thread Development


I'm trying to get a value for a specific variable to tell if a  
transaction is complete on iphone. In the didFinishLoading delegate  
method I have placed this code:


NSString * aString =[theWebView  
stringByEvaluatingJavaScriptFromString 
:@"document.getElementsByName(\"encrypted\").value"];

NSLog(@"AString: %@",aString);

The string is empty. I get nothing although I clearly have a field  
variable named encrypted in the html source of the page it is loading,  
and that field has a value because I have assigned it the value  
"Success!"

So I am concerned... What am I doing wrong?

I've spent half the morning googling examples, and looking on the  
developer site and all the examples and information tell me that my  
code should be good but it isn't.

___

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

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

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

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


How do I compute the screen width of a particular font?

2009-08-05 Thread Frederick C. Lee
Greetings:I need to adjust a UILabel's width per with of its text.
What I did was to get the text's length via [NSString length].   Of course,
the displayed UILabel width is too narrow to fully display the actual
string.
So I believe I need to compute the true width based on the number of
font-sized characters.

Is there a simple, quick way to do this?

Regards,

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: How do I compute the screen width of a particular font?

2009-08-05 Thread I. Savant

On Aug 5, 2009, at 3:46 PM, Frederick C. Lee wrote:


Greetings:I need to adjust a UILabel's width per with of its text.
What I did was to get the text's length via [NSString length].   Of  
course,

the displayed UILabel width is too narrow to fully display the actual
string.
So I believe I need to compute the true width based on the number of
font-sized characters.


  The "width of a font" doesn't really make sense. It might make  
sense to look for the width of the widest glyph in a font, but unless  
it's a fixed-width font, that metric is not the same as "the width of  
the attributed string, as rendered with the given attributes,  
including font, paragraph settings, etc." I'd recommend reading all  
font-related documentation.




Is there a simple, quick way to do this?



  A quick look at the UILabel class reference shows that's a subclass  
of UIView. UIView has -sizeToFit, which, "Resizes and moves the  
receiver view so it just encloses its subviews." In the case of a  
UILabel, I would expect this (as on the Mac platform) to size to fit  
its attributed string keeping all its attributes in mind.


  Disclaimer: I'm not an iPhone developer, but I am a Mac desktop  
developer. Much of Cocoa works the same across both platforms. The UI- 
related stuff differs in some key areas, but apparently not this one.


--
I.S.


___

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

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

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

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


Re: How do I compute the screen width of a particular font?

2009-08-05 Thread Randall Meadows

On Aug 5, 2009, at 1:46 PM, Frederick C. Lee wrote:


Greetings:I need to adjust a UILabel's width per with of its text.
What I did was to get the text's length via [NSString length].   Of  
course,

the displayed UILabel width is too narrow to fully display the actual
string.
So I believe I need to compute the true width based on the number of
font-sized characters.

Is there a simple, quick way to do this?


myUILabel.text = @"Some text.";
[myUILabel sizeToFit];


___

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

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

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

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


[OT] Re: Generating random numbers

2009-08-05 Thread Alastair Houghton

On 5 Aug 2009, at 17:54, Agha Khan wrote:


Dear Mahaboob:
Many people have answered this question but I will take this route.

First of all you only have call srandom once in you program. Best  
place is when you are going to load the object.


While this entire thread should never have been on *COCOA*-dev in the  
first place (it has nothing to do with Cocoa), I can't really stand by  
and let your post sit in the list archives unanswered for some poor  
soul to stumble across.


Not only is your RANDOM_INT() macro problematic (it generates biased  
results if the range is anything other than a power of 2, and you've  
used reserved identifiers [you mustn't use anything starting with an  
"_" in your own code... all such identifiers are reserved for the  
implementation]), but your shuffle algorithm is about the worst  
possible also (it produces biased results).


Amazingly I recall reading that one of the on-line gambling websites  
was actually using that algorithm to shuffle decks of cards(!), which  
meant it was possible to predict the sequence with some degree of  
accuracy.  Even in a casual computer game, such an algorithm is not  
good, but if money is involved it might even be illegal.


This is a good page to read on this topic:

  

Kind regards,

Alastair.

--
http://alastairs-place.net



___

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

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

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

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


Re: How do I compute the screen width of a particular font?

2009-08-05 Thread Frederick C. Lee
Interesting.I finally tried:  [NSString sizeWithFont:<>] as follows.

CGSize strSize = [item.title sizeWithFont:[UIFont
systemFontOfSize:TEXT_FONT_SIZE]];

CGRect centralTitleRect = CGRectMake(TITLE_OFFSET, (rowHeight -
TITLE_LINE_HEIGHT)/ 3.0, strSize.width, TITLE_LINE_HEIGHT);

UILabel *titleLabel = [[UILabel alloc] initWithFrame:centralTitleRect];



I'll try your method to see if I get the same effect.

Thanks.


Ric.

On Wed, Aug 5, 2009 at 3:54 PM, Randall Meadows  wrote:

> On Aug 5, 2009, at 1:46 PM, Frederick C. Lee wrote:
>
>  Greetings:I need to adjust a UILabel's width per with of its text.
>> What I did was to get the text's length via [NSString length].   Of
>> course,
>> the displayed UILabel width is too narrow to fully display the actual
>> string.
>> So I believe I need to compute the true width based on the number of
>> font-sized characters.
>>
>> Is there a simple, quick way to do this?
>>
>
> myUILabel.text = @"Some text.";
> [myUILabel sizeToFit];
>
>
>
___

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

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

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

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


Re: [iPhone] Webview stringByEvaluatingJavaScriptFromString

2009-08-05 Thread Fritz Anderson

On 5 Aug 2009, at 2:08 PM, Development wrote:

I'm trying to get a value for a specific variable to tell if a  
transaction is complete on iphone. In the didFinishLoading delegate  
method I have placed this code:


NSString * aString =[theWebView  
stringByEvaluatingJavaScriptFromString 
:@"document.getElementsByName(\"encrypted\").value"];

NSLog(@"AString: %@",aString);

The string is empty. I get nothing although I clearly have a field  
variable named encrypted in the html source of the page it is  
loading, and that field has a value because I have assigned it the  
value "Success!"

So I am concerned... What am I doing wrong?

I've spent half the morning googling examples, and looking on the  
developer site and all the examples and information tell me that my  
code should be good but it isn't.



We have only your word that your HTML and Objective-C are  
indistinguishable from perfect. If they are perfect, then you don't  
have a bug at all. If they aren't, then you've given us no way to help  
you.


Show your code, including the stripped-down HTML tree down to element  
"encrypted," how you initialize theWebView, and how you load it with  
the HTML. Tell us things you learned from the debugger, such as what  
aString _does_ contain, and whether theWebView is nil.


Are you displaying theWebView? If not, have you ascertained whether  
DOM accessors work on a UIWebView that may not have been rendered? (I  
confess I don't know, but it's one of the things I'd check.)


— F

--
Fritz Anderson -- Xcode 3 Unleashed: Now in its second printing -- 


___

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

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

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

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


How do I change a UITableView's row-cell's color upon user selection?

2009-08-05 Thread Frederick C. Lee
Greetings:

The default selection color is blue.   I want to use a different color
upon user selection.   Here's my code:


 (void)tableView:(UITableView *)theTableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath  {

UITableViewCell *cell = [theTableView cellForRowAtIndexPath:indexPath];

cell.contentView.backgroundColor = [UIColor redColor];   // ... for
example, I want to change to 'red'.

[theTableView deselectRowAtIndexPath:indexPath animated:NO];

DJMyJournalFolderCellController *controller = [self.feedItems
objectAtIndex:indexPath.row];

DJNewsSectionViewController *viewController =
[[DJNewsSectionViewController alloc] initWithNibName:@"RSSViewController"
bundle:nil];

viewController.section = controller.item;

[[self navigationController] pushViewController:viewController
animated:YES];

[viewController release];

}




I tried to force a re-display with [ setNeedsDisplay] but that
doesn't work; probably need to change to boundaries for it to notice.

Is there a way to change the default 'blue' to a different color upon
selecting the row?



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: [iPhone] Webview stringByEvaluatingJavaScriptFromString

2009-08-05 Thread Development


The html is pretty straight forward. It is created with php and is as  
follows when you view source from the page:



it is also within a form.

the UIWebView is built in IB and linked up. It loads correctly and the  
'real' page passes it's variables along to the next correctly. The  
webview even posts the variable I need posted to it. Also when I test  
this code the webview is visible on screen.

below is the url loading code:

NSURL * url = [NSURL URLWithString:@"http://mysite.com/test.php";];


	NSString *myRequestString = [NSString stringWithFormat:@"appVersion= 
%i&userID=%@&password=%@",appVersion,passwordHolder];


	NSData *myRequestData = [myRequestString  
dataUsingEncoding:NSUTF8StringEncoding];



	NSMutableURLRequest *request = [ [ NSMutableURLRequest alloc ]  
initWithURL:url];

[ request setHTTPMethod: @"POST" ];
[ request setHTTPBody: myRequestData ];
	[request setValue:@"application/x-www-form-urlencoded"  
forHTTPHeaderField:@"content-type"];


webViewContainer.autoresizesSubviews = YES;
	webViewContainer.autoresizingMask = (UIViewAutoresizingFlexibleWidth  
| UIViewAutoresizingFlexibleHeight);

webView.delegate = self;
	webView.autoresizingMask = (UIViewAutoresizingFlexibleWidth |  
UIViewAutoresizingFlexibleHeight);



[webView loadRequest:request];


On Aug 5, 2009, at 2:33 PM, Fritz Anderson wrote:

NSString * aString =[theWebView  
stringByEvaluatingJavaScriptFromString 
:@"document.getElementsByName(\"encrypted\").value"];

NSLog(@"AString: %@",aString);


___

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

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

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

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


Re: [iPhone] Webview stringByEvaluatingJavaScriptFromString

2009-08-05 Thread glenn andreas


On Aug 5, 2009, at 2:08 PM, Development wrote:



I'm trying to get a value for a specific variable to tell if a  
transaction is complete on iphone. In the didFinishLoading delegate  
method I have placed this code:


NSString * aString =[theWebView  
stringByEvaluatingJavaScriptFromString 
:@"document.getElementsByName(\"encrypted\").value"];

NSLog(@"AString: %@",aString);

The string is empty. I get nothing although I clearly have a field  
variable named encrypted in the html source of the page it is  
loading, and that field has a value because I have assigned it the  
value "Success!"

So I am concerned... What am I doing wrong?



Set a break point in the debugger at that point.

Use gdb to make sure that things are actually like you expect them to  
be, using a series of "po" commands calling [theWebView  
stringByEvaluatingJavaScriptFromString:] with various queries.


Since stringByEvaluatingJavaScriptFromString doesn't do any attempt at  
stringification of objects (and will return an empty string instead  
something like "[DOMElement]"), you'll probably want to do it  
manually, such as:


po [theWebView stringByEvaluatingJavaScriptFromString @"'' +  
document.getElementByName('encrypted')"]


That will show you if there really is something there like you expect.

Most likely, you're calling it at the wrong time, before the content  
has been fully loaded/rendered...




Glenn Andreas  gandr...@gandreas.com
  wicked fun!
Mad, Bad, and Dangerous to Know

___

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

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

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

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


Re: [iPhone] networking

2009-08-05 Thread glenn andreas


On Aug 4, 2009, at 4:42 PM, Shawn Erickson wrote:

On Tue, Aug 4, 2009 at 11:13 AM, Luke the Hiesterman> wrote:


On Aug 4, 2009, at 11:10 AM, James Lin wrote:


Bonjour is for local area network, right?


No, Bonjour is applicable to any networking, local or wide area.  
Here's some

sample code.

http://developer.apple.com/iphone/library/samplecode/BonjourWeb/index.html


Well ad-hoc discovery only works on the local sub-net or across
bridged sub-nets. To do service discovery across sub-nets would
require a known DNS server publishing the existence of services and
how to contact them via public IP addresses.



Of course, in the context of the original question (re: iPhone  
networking), the iPhone is almost never going to have a public IP  
address (being hidden behind WiFi or cell phone NATs).



Glenn Andreas  gandr...@gandreas.com
  wicked fun!
Mad, Bad, and Dangerous to Know

___

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

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

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

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


Re: [iPhone] networking

2009-08-05 Thread Kyle Sluder

On Aug 4, 2009, at 4:42 PM, Shawn Erickson wrote:


Of course, in the context of the original question (re: iPhone  
networking), the iPhone is almost never going to have a public IP  
address (being hidden behind WiFi or cell phone NATs).


Assuming cell carriers don't get off their butts and implement IPv6.  
There's no guarantee of that, especially if China gets the iPhone.


--Kyle Sluder



___

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

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

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

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


Disabling Exposé in SystemUIMode

2009-08-05 Thread Pierce Freeman
Hi Everyone:

I am wondering if anyone knows of a way to disable Exposé in SystemUIMode.
I am using this class to create a kiosk-based application and don't want the
user to be able to switch between other windows.  If there isn't a way to do
this inside the class, is there another class that can accomplish this
instead?


Thanks for any help.


___

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

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

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

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


Re: Tell which type is in NSValue?

2009-08-05 Thread aaron smith
Thanks for the info. Yeah I have a method right now that accepts
NSValue, and I'm figuring out what is in the value. But I'm going to
add methods that explicitly require NSPoint, etc. Thanks again for the
help, much appreciated. -A

On Wed, Aug 5, 2009 at 4:13 AM, Graham Cox wrote:
>
> On 05/08/2009, at 6:27 PM, Alastair Houghton wrote:
>
>> Usually when you're using NSValue, you already know what type you're
>> dealing with.  If you have a situation where you need to distinguish between
>> several different things, you might be better off making some wrapper
>> classes (or maybe subclasses of NSValue, which is how NSNumber works).
>
>
> Not only that, but note this from the docs for [NSNumber objCType]: "Special
> Considerations The returned type does not necessarily match the method the
> receiver was created with."
>
> This makes it very hard to preserve type information using NSNumbers -
> integers and floats usually end up converted internally to doubles, I found.
> The same warning does not appear to be applied to NSValue however. If type
> is of critical importance though, I'd store it explicitly in an object of
> your own devising.
>
> --Graham
>
>
>
___

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

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

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

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


Setting the width of a segment to 0 in NSSegmentedControl doesn't work so well

2009-08-05 Thread Peter Zegelin
My application has a dynamic segmented control, where the user can  
specify that each segment has an icon, text, or both. However I am  
having trouble correctly resizing a segment.


According to the docs, calling

- (void)setWidth:(CGFloat)width forSegment:(NSInteger)segment

with 0 for the width " Specify the value 0 if you want the segment to  
be sized to fit the available space automatically."


Unfortunately this only seems to work if the segment is text only. If  
the segment has an icon, or an icon + text then resizing doesn't work,  
as any segment with an icon doesn't include space for the icon. As a  
work around I have tried setting the width to 0 and then immediately  
getting the width ( with the intention of adding say 25 for the icon)  
but it also returns 0.


Does anyone know what might be going on and a workaround if necessary?

Thanks!

Peter
___

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

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

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

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


Re: Disabling Exposé in SystemUIMode

2009-08-05 Thread Ricky Sharp


On Aug 5, 2009, at 8:45 PM, Pierce Freeman wrote:

I am wondering if anyone knows of a way to disable Exposé in  
SystemUIMode.
I am using this class to create a kiosk-based application and don't  
want the
user to be able to switch between other windows.  If there isn't a  
way to do

this inside the class, is there another class that can accomplish this
instead?



Using SetSystemUIMode disables Expose in my app just fine.  I call it  
with these parameters:


OSStatus status = SetSystemUIMode (kUIModeAllHidden,  
kUIOptionDisableProcessSwitch);


There's a technote here which covers the options (although seems a bit  
outdated)




___
Ricky A. Sharp mailto:rsh...@instantinteractive.com
Instant Interactive(tm)   http://www.instantinteractive.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: Disabling Exposé in SystemUIMode

2009-08-05 Thread Pierce Freeman
Hi Ricky:

Which version of OS X are you using?  With the latest of Leopard, it just
doesn't seem to work.


On 8/5/09 7:34 PM, "Ricky Sharp"  wrote:

> 
> On Aug 5, 2009, at 8:45 PM, Pierce Freeman wrote:
> 
>> I am wondering if anyone knows of a way to disable Exposé in
>> SystemUIMode.
>> I am using this class to create a kiosk-based application and don't
>> want the
>> user to be able to switch between other windows.  If there isn't a
>> way to do
>> this inside the class, is there another class that can accomplish this
>> instead?
> 
> 
> Using SetSystemUIMode disables Expose in my app just fine.  I call it
> with these parameters:
> 
> OSStatus status = SetSystemUIMode (kUIModeAllHidden,
> kUIOptionDisableProcessSwitch);
> 
> There's a technote here which covers the options (although seems a bit
> outdated)
> 
> 
> 
> ___
> Ricky A. Sharp mailto:rsh...@instantinteractive.com
> Instant Interactive(tm)   http://www.instantinteractive.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


FYI - new debug & profile libraries are out

2009-08-05 Thread Nick Zitzmann
I didn't see anyone else mention this, so I have good news and bad  
news...


The good news is, yesterday new debug & profile libraries appeared on  
ADC. Woohoo!


The bad news is, they're for 10.5.7. 10.5.8 was just launched today,  
so if you've already upgraded, then you'll have to wait a while for  
new libraries to be released. D'oh!


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


Garbage Collection, Core Foundation, and toll-free bridging

2009-08-05 Thread Marco S Hyman

I assume that just because I can toll-free bridge something
between core foundation and NSFoo I still have to worry about
CFretain/CFrelease in a GC app.  Correct?

Example:

Assume image is an CGImageSourceRef.

NSDictionary *metadata =
(NSDictionary *) CGImageSourceCopyPropertiesAtIndex(image, 0, NULL);

CFRelease((CFDictionaryRef) metadata);

or alternately

NSDictionary *metadata = (NSDictionary *)
NSMakeCollectable(CGImageSourceCopyPropertiesAtIndex(image, 0, NULL));

Is that correct?

/\/\arc

___

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

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

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

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


General approach to networking/server problem?

2009-08-05 Thread Graham Cox
A general question. Suppose I wanted to write a Cocoa application that  
could be accessed via a PHP script running on another machine on the  
local network, what would the general shape of the solution look like?  
The Cocoa app could run either as a command-line tool or a continually  
running server, whatever makes most sense. The PHP script? I know  
nothing


The server would return an opaque block of data or text, which the  
script would end up emailing. The input to the server would be a  
variety of parameters, mostly in string form. The protocol between the  
script an the server could be entirely private, or could use existing  
protocols such as HTTP. How would you do it?


--Graham


___

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

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

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

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


Re: Garbage Collection, Core Foundation, and toll-free bridging

2009-08-05 Thread Bill Bumgarner

On Aug 5, 2009, at 8:11 PM, Marco S Hyman wrote:


I assume that just because I can toll-free bridge something
between core foundation and NSFoo I still have to worry about
CFretain/CFrelease in a GC app.  Correct?


Correct.


Example:

Assume image is an CGImageSourceRef.

   NSDictionary *metadata =
(NSDictionary *) CGImageSourceCopyPropertiesAtIndex(image, 0, NULL);
   
   CFRelease((CFDictionaryRef) metadata);

or alternately

   NSDictionary *metadata = (NSDictionary *)
	NSMakeCollectable(CGImageSourceCopyPropertiesAtIndex(image, 0,  
NULL));


Is that correct?


Either will work.  You are better off using NSMakeCollectable() as it  
the collector is then free to reap the object at its convenience.   As  
well NSMakeCollectable() offers more opportunity for future  
optimizations than does CFRelease().


b.bum

___

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

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

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

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


Re: Garbage Collection, Core Foundation, and toll-free bridging

2009-08-05 Thread Rob Keniger


On 06/08/2009, at 1:11 PM, Marco S Hyman wrote:


I assume that just because I can toll-free bridge something
between core foundation and NSFoo I still have to worry about
CFretain/CFrelease in a GC app.  Correct?

Example:

Assume image is an CGImageSourceRef.

   NSDictionary *metadata =
(NSDictionary *) CGImageSourceCopyPropertiesAtIndex(image, 0, NULL);
   
   CFRelease((CFDictionaryRef) metadata);

or alternately

   NSDictionary *metadata = (NSDictionary *)
	NSMakeCollectable(CGImageSourceCopyPropertiesAtIndex(image, 0,  
NULL));


Is that correct?


Please don't start a new topic by replying to an existing thread,  
create a new message.


To answer your question: Yes.

http://developer.apple.com/documentation/Cocoa/Conceptual/GarbageCollection/Articles/gcCoreFoundation.html

--
Rob Keniger



___

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

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

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

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


Re: Garbage Collection, Core Foundation, and toll-free bridging

2009-08-05 Thread Dave Keck
> Is that correct?

Yes. A note though: since you're using NSMakeCollectable() (instead of
CFMakeCollectable()), the cast to (NSDictionary *) is unnecessary -
which is one of the main benefits of using the NS* version.
___

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

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

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

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


Avoiding expose animation for NSWindow

2009-08-05 Thread Matt
I'm trying to create a borderless window which acts as a mask for the
desktop, sitting one level above the icons and staying in place as the
user works and switches between other apps and spaces. Most of this
behavior I can get with -setCollectionBehavior and -setLevel, but the
problem I'm having is getting the NSWindow to _not_ animate when
expose's various animations trigger (eg, Reveal Desktop). In this case
I need the window to behave the same as the dock or the desktop itself
would, staying in place while the other windows animate over it.

I have poked around in the kiosk tech notes as was recently mentioned
as well as the major classes involved but can't seem to find how to go
about achieving this effect?

Any pointers or advice greatly appreciated.
Thanks very much,
-Matt
___

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

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

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

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


Re: [iPhone] Webview stringByEvaluatingJavaScriptFromString

2009-08-05 Thread Andrew Farmer

On 5 Aug 2009, at 12:08, Development wrote:
NSString * aString =[theWebView  
stringByEvaluatingJavaScriptFromString 
:@"document.getElementsByName(\"encrypted\").value"];



This Javascript will never work correctly, no matter whether it's from  
HTML or from ObjC. getElementsByName returns a collection, not an  
element.

___

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

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

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

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


NSMenuItem addTarget & retain

2009-08-05 Thread Remko Tronçon
Hi,

Is the following piece of code legal?

Foo* foo = [[Foo aloc] init];
NSMenuItem* item = [[NSMenuItem alloc] initWithTitle: @"Item" action:
@selector(action:) keyEquivalent: @""];
[item setTarget: foo];
[foo release];

Unless I have a problem in some other part of my code, it seems that
releasing the 'foo' object is not allowed. In my limited knowledge of
Cocoa, I would expect that NSMenuItem retains foo. Is this a wrong
assumption?

thanks,
Remko
___

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

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

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

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


Using NSTimer and CGEventPost causes problems

2009-08-05 Thread Björn Bollensdorff

Hi all,

I'm trying to implement a remote control for an application. The mouse  
data is send to the application through a socket which is checked  
regularly by a function triggered by a NSTimer. The data is then  
transfered into the corresponding CGEvent. Interestingly this works as  
long as I do not perform a mouse down on a NSButton or something  
similar. If I hit an active element the NSTimer does not fire anymore.
I simplified the problem as much as possible getting to the following  
small application that does not use socket communication anymore.
There are two buttons, a checkbox and a label. The first button  
triggers the mouse event and the second is the target. The checkbox  
sets the position of the mouseEvent. If it is unchecked the mouse down  
and up are performed somewhere in the applications window. If it is  
checked they are performed on the target button. To see if the action  
bound to the target button was triggered the label changes.
If the first button is activated I generate a CGEvent MouseDown and  
start a NSTimer. The NSTimer triggers a function that generates a  
CGEvent MouseUp. The behavior of the small application now depends on  
where the MouseDown is performed. If there is no element underneath  
it, the NSTimer fires and the Mouse Up is performed. If an element is  
hit the NSTimer does not fire until I manually hit the mouse button.


I'm using CGEventCreateMouseEvent to create the MouseEvent and  
CGEventPost to post the mouse event. I tried CGPostMouseEvent, too,  
getting the same result.


Does anybody know how to can resolve that problem?

Thanks a lot
Björn

I uploaded a zip-file with the project to:

http://user.cs.tu-berlin.de/~bbolle/MouseEventTest.zip

I'm using Mac OS X 10.5.7 and XCode 3.1.2

The source code of the small application follows:

@implementation EventTest

-(IBAction) startButton:(id)sender
{
NSScreen* mainScreen = [NSScreen mainScreen];
NSRect screenSize = [mainScreen frame];

if([_checkBox intValue]) {

		_position = CGPointMake([_window frame].origin.x + 50, 
(screenSize.size.height- [_window frame].origin.y-60));

} else {
		_position = CGPointMake([_window frame].origin.x + 15, 
(screenSize.size.height- [_window frame].origin.y-15));

}

  	CGEventRef event = CGEventCreateMouseEvent(NULL,  
kCGEventLeftMouseDown, _position, kCGMouseButtonLeft);

CGEventPost(kCGHIDEventTap, event);

	_ticker = [[NSTimer scheduledTimerWithTimeInterval: 1.0/60.0 target:  
self selector: @selector(timerHandle) userInfo: nil repeats: YES]  
retain];

NSLog(@"Timer started");


}

-(IBAction) testButton:(id)sender
{
[_testString setStringValue:@"YES"];
}

-(void) timerHandle
{

NSLog(@"Timer executed");
NSLog(@"Mouse Up");
  	CGEventRef event = CGEventCreateMouseEvent(NULL,  
kCGEventLeftMouseUp, _position, kCGMouseButtonLeft);

CGEventPost(kCGHIDEventTap, event); 
[_ticker invalidate];
[_ticker release];

}

@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: [iPhone] networking

2009-08-05 Thread Kaelten
Just brainstorming theory here, but it might be made much easier if
you had a server act as an intermediary, even if all that server does
is 'introduce' the two iphones to each other.

Bryan McLemore
Kaelten



On Tue, Aug 4, 2009 at 1:10 PM, James Lin wrote:
> Correct me if I am wrong...but from what i have read so far...
>
> Bonjour is for local area network, right?
>
> What I am trying to do is to get 2 iPhones located in 2 different part of
> the world to connect to each other on the internet.
> Can Bonjour work?
>
> Thanx in advance...
>
> James
> On 2009/8/5, at 上午 2:02, glenn andreas wrote:
>
>>
>> On Aug 4, 2009, at 12:49 PM, James Lin wrote:
>>
>>> I am trying to make the iPhone a server and a client at the same time...
>>>
>>> What I am trying to accomplish...
>>>
>>> 1. iPhone running my application opens a "server" socket and listens for
>>> incoming network connection from another iPhone running the same
>>> application.
>>> 2. The server socket has an "ip address" that i can register with my
>>> php/mysql server.
>>> 3. Another iPhone running my same app acts as the client gets the iPhone
>>> server's ip address from the server and make connection to the server
>>> iPhone.
>>> 4. The client iPhone sends a string "hello, I am James" to the server
>>> iPhone and the server iPhone reply with the user's choice of either "Hi,
>>> Nice to meet you" or "Get lost!" strings.
>>
>>
>> Unless the two phones are on the same local WiFi network, due to the way
>> that various NATs (especially with cell phone networking), a client will
>> almost certainly not be able  to connect to a server running on the phone.
>>  Basically, the phone see only a local (private) network, and will have an
>> address such as 10.3.5.12.  Unfortunately, that IP address is meaningless
>> outside of local network (there is no way for a  remote phone, which may
>> have the exact same address, to find 10.3.5.12 as being your local phone).
>>
>> Given that trying to support phone based servers isn't going to work
>> except for within the same WiFi network, you might as well instead use
>> Bonjour for one  phone to discover the other phone (which will automatically
>> handle finding/resolving/advertising ip address/ports).
>>
>>
>> Glenn Andreas                      gandr...@gandreas.com
>>  wicked fun!
>> Mad, Bad, and Dangerous to Know
>>
>
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/kaelten%40gmail.com
>
> This email sent to kael...@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


Design Question

2009-08-05 Thread Kaelten
I have an application I'm working on where I'm using mainly Bindings
for communicating with the UI, but I find myself in situations where
I'm not getting all the data updates to the UI.

These lack of updates seem to stem either from dependent keys, loose
coupling between objects, to-many relationships, and nullable
relationships.

I work around the first one mostly with
setKeys:triggerChangeNotificationsForDependentKey: (I'm targeting
10.4).

It's the other three cases that I'm having a slight issue with.  One
thought I had is that I could craft notifications so that the loosely
coupled objects and nullable relationships can listen for something
that'd cause them to need to update.

Unfortunately, this is my first cocoa application and I'm working in a
fairly sizable vacuum so any input you guys have would be greatly
appreciated.


Bryan McLemore
Kaelten
___

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

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

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

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


GC and NSCFType finalize

2009-08-05 Thread dp
I recently updated some older code and converted to GC in the process.  
Most of the time, things run fine. But every now and then I seem to  
run into a CFRelease and/or a finalize down in system libraries or  
Apple Frameworks. The ImageIO framework and CFDateFormatter seem to be  
the culprits in some cases. How do I best go about debugging these and/ 
or working around them? Are these bugs in the frameworks or just a GC  
issue I need to do something about? Crash stacks below.


thanks in advance




Thread 1 Crashed:
0   com.apple.ImageIO.framework   	0x0396c6e4 jp2_family_src::close()  
+ 10
1   com.apple.ImageIO.framework   	0x0396c67a  
_cg_JP2TearDownDecompressor + 28
2   com.apple.ImageIO.framework   	0x0396c64f JP2ReleaseInfoCallback +  
21

3   com.apple.Foundation0x01a95a81 -[NSCFType finalize] + 49
4   libobjc.A.dylib 0x0087c6b6 finalizeOneObject + 56
5   libauto.dylib 	0x02ae0d9b  
foreach_block_do(auto_zone_cursor*, void (*)(void*, void*), void*) + 123

6   libobjc.A.dylib 0x0087c87b batchFinalize + 220
7   libobjc.A.dylib   	0x0087cb42  
batchFinalizeOnTwoThreads + 98
8   libauto.dylib 	0x02ae1efe  
auto_collect_internal(Auto::Zone*, int) + 782
9   libauto.dylib 	0x02ae2b7f  
auto_collection_thread(void*) + 111

10  libSystem.B.dylib   0x006a6155 _pthread_start + 321
11  libSystem.B.dylib   0x006a6012 thread_start + 34


Thread 1 Crashed:
0   com.apple.ImageIO.framework   	0x03a13637  
kdu_params::~kdu_params() + 523
1   com.apple.ImageIO.framework   	0x03a27581  
siz_params::~siz_params() + 37
2   com.apple.ImageIO.framework   	0x03a02984  
kd_codestream::~kd_codestream() + 574
3   com.apple.ImageIO.framework   	0x0396d3ea  
kdu_codestream::destroy() + 80
4   com.apple.ImageIO.framework   	0x0396d36e  
kdrc_codestream::~kdrc_codestream() + 100
5   com.apple.ImageIO.framework   	0x0396d2f4  
kdrc_codestream::detach(kdrc_stream*) + 246
6   com.apple.ImageIO.framework   	0x039ead8e  
kdrc_stream::~kdrc_stream() + 76
7   com.apple.ImageIO.framework   	0x0396cfed  
kdu_region_compositor::remove_stream(kdrc_stream*, bool) + 229
8   com.apple.ImageIO.framework   	0x039eae36  
kdrc_layer::~kdrc_layer() + 66
9   com.apple.ImageIO.framework   	0x0396ce65  
kdu_region_compositor::remove_compositing_layer(int, bool) + 425
10  com.apple.ImageIO.framework   	0x0396cb8e  
kdu_region_compositor::pre_destroy() + 42
11  com.apple.ImageIO.framework   	0x03a37925  
MyRegionCompositor::~MyRegionCompositor() + 43
12  com.apple.ImageIO.framework   	0x0396c6a6  
_cg_JP2TearDownDecompressor + 72
13  com.apple.ImageIO.framework   	0x0396c64f JP2ReleaseInfoCallback +  
21

14  com.apple.Foundation0x01a95a81 -[NSCFType finalize] + 49
15  libobjc.A.dylib 0x0087c6b6 finalizeOneObject + 56
16  libauto.dylib 	0x02ae0d9b  
foreach_block_do(auto_zone_cursor*, void (*)(void*, void*), void*) + 123

17  libobjc.A.dylib 0x0087c87b batchFinalize + 220
18  libobjc.A.dylib   	0x0087cb42  
batchFinalizeOnTwoThreads + 98
19  libauto.dylib 	0x02ae1efe  
auto_collect_internal(Auto::Zone*, int) + 782
20  libauto.dylib 	0x02ae2b7f  
auto_collection_thread(void*) + 111

21  libSystem.B.dylib   0x006a6155 _pthread_start + 321
22  libSystem.B.dylib   0x006a6012 thread_start + 34


Thread 1 Crashed:
0   ??? 0xb7143602 0 + 3071555074
1   libicucore.A.dylib	0x02b2e8a1  
icu::DateFormat::~DateFormat() + 59
2   libicucore.A.dylib	0x02b716b2  
icu::SimpleDateFormat::~SimpleDateFormat() + 94
3   com.apple.CoreFoundation  	0x00a010c9  
__CFDateFormatterDeallocate + 25

4   com.apple.Foundation0x01a95a81 -[NSCFType finalize] + 49
5   libobjc.A.dylib 0x0087c6b6 finalizeOneObject + 56
6   libauto.dylib 	0x02ae0d9b  
foreach_block_do(auto_zone_cursor*, void (*)(void*, void*), void*) + 123

7   libobjc.A.dylib 0x0087c87b batchFinalize + 220
8   libobjc.A.dylib   	0x0087cb42  
batchFinalizeOnTwoThreads + 98
9   libauto.dylib 	0x02ae1efe  
auto_collect_internal(Auto::Zone*, int) + 782
10  libauto.dylib 	0x02ae2b7f  
auto_collection_thread(void*) + 111

11  libSystem.B.dylib   0x006a6155 _pthread_start + 321
12  libSystem.B.dylib   0x006a6012 thread_start + 34
___

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

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

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

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


Loading an AS dict that defines 'point' also causes 'points' to be defined??

2009-08-05 Thread David Springer
Folks,

I recently switched to using an .sdef in my Cocoa app for defining AS event
handlers.  The problem is that suddenly it looks like my app defines the
property 'points' and this breaks other apps which send AS events to mine.

In my .sdef, I do not define a 'point' or 'points' property, nor do I do
this in code.  When I use Script Editor, it shows that 'point' is a keyword
but 'points' is not, unless my app is running.

Any clues as to what is going on here?  Is there a way I can "undefine"
'points' in my .sdef, or in code?  Is there a way to debug this, either via
Cocoa APIs or some tool that shows me what properties are being set by which
script/script addition?

Thanks!
- Dave.S
___

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

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

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

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


adding a sub menu to multiple super menus?

2009-08-05 Thread David M. Cotter
in carbon, you can have a sub menu that is used in more than one super  
menu.


is there a trick to get this to go in Cocoa?  otherwise i'm stuck with  
cloning and managing all the clones (eg: if i enable a menu item, or  
if i change the key shortcut, or change the item text, i have to find  
all the clones and perform the same op on them too, it's a real pain)


___

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

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

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

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


IB connections - newbie question

2009-08-05 Thread Oftenwrong Soong
Hi all,

I am making a NSDocument based app. In the NIB for the document window, I need 
to create a connection to a "global" data object (think singleton). This 
"global" data is used when creating the document, but isn't part of the 
document.

Normally I'd make a connection by dragging a NSObject into the NIB but that 
would instantiate a separate object for each open document. I want all open 
document(s) to share the same object.

How can I create such a connection between the NIB and my code?

Thanks all,
Soong



  
___

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

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

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

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


NSOutlineView Not Updating After Adding Items

2009-08-05 Thread Mark Szymczyk
I'm using NSOutlineView and NSTreeController to display and edit an  
NSXMLDocument on Mac OS X 10.5. The application uses bindings and is  
based on the "Using Tree Controllers with NSXML Objects" example in  
the Tree-Based XML Programming Guide. I get some strange behavior when  
I add elements to the XML document.


If the parent has not been expanded in the outline view when I add a  
new element to it, the outline view behaves properly. When I expand  
the parent in the outline view I can see the new element has been  
added. Once I expand the parent, a problem arises. Any new elements I  
add to that parent do not appear in the outline view. Collapsing the  
parent in the outline view and resizing the window do not help. The  
elements get added to the XML tree. They're just not getting added to  
the outline view. I know the elements are being added to the XML tree  
because saving the document, closing it, and reopening it makes the  
added elements appear in the outline view.


I have tried calling the outline view's reloadData method and the tree  
controller's rearrangeObjects method. I have also tried calling the  
outline view's reloadItem:reloadChildren method, but the outline view  
still not does not update after expanding a parent element in the  
outline view. What do I have to do to get the outline view to display  
the proper information?


Mark


___

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

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

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

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


Re: [iPhone] Webview stringByEvaluatingJavaScriptFromString

2009-08-05 Thread Pavel Dudrenov
getElementsByName, as the name applies, returns a collection.

On Wed, Aug 5, 2009 at 12:08 PM, Development wrote:

>
> I'm trying to get a value for a specific variable to tell if a transaction
> is complete on iphone. In the didFinishLoading delegate method I have placed
> this code:
>
> NSString * aString =[theWebView stringByEvaluatingJavaScriptFromString:@
> "document.getElementsByName(\"encrypted\").value"];
>NSLog(@"AString: %@",aString);
>
> The string is empty. I get nothing although I clearly have a field variable
> named encrypted in the html source of the page it is loading, and that field
> has a value because I have assigned it the value "Success!"
> So I am concerned... What am I doing wrong?
>
> I've spent half the morning googling examples, and looking on the developer
> site and all the examples and information tell me that my code should be
> good but it isn't.
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/dudrenov%40gmail.com
>
> This email sent to dudre...@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


Mac OS X 10.5.8 update breaks tokenize function in -[NSXMLNode objectsForXQuery:error:]

2009-08-05 Thread Michael Link
I noticed that the recent update of Mac OS X 10.5.8 breaks  
compatibility with previous versions regarding XQuery statements in  
NSXMLNode, specifically using the XQuery function tokenize. I  
originally reported this bug against a future version of Mac OS X and  
now seems to have slipped into the latest update of Mac OS X 10.5.


rdar://problem/7037807

The following code works on Mac OS X 10.5.0 - 10.5.7 but does not work  
on Mac OS X 10.5.8.


@interface Bug7037807 : NSObject
{
NSXMLDocument* _document;
}
- (void)performXQuery:(NSString*)query;
@end

@implementation Bug7037807

- (id)init
{
if (self = [super init]) {
		_document = [[NSXMLDocument alloc]  
initWithXMLString:@"titleheaderh1>astring, bstring, cstring, dstring, estringastring &  
bstring & cstring & dstring & estring"  
options:NSXMLDocumentTidyHTML error:nil];

}

return self;
}

- (void)awakeFromNib
{
[self performXQuery:@"/descendant-or-self::p[1]"];
[self performXQuery:@"xs:string(/descendant-or-self::p[1])"];
	[self performXQuery:@"tokenize(xs:string(/descendant-or-self::p[1]),  
',')"];

}

- (void)performXQuery:(NSString*)query
{
NSError* __error = nil;
NSArray* __results;

__results = [_document objectsForXQuery:query error:&__error];

if (!__results) {
NSLog(@"error: %@", __error);
}
else {
NSLog(@"results: %@", __results);
}
}

@end


Output on Mac OS X 10.5.0 - 10.5.7

2009-08-05 23:34:49.428 Bug7037807[577:10b] results: (
astring, bstring, cstring, dstring, estring

)
2009-08-05 23:34:49.431 Bug7037807[577:10b] results: (
"astring, bstring, cstring, dstring, estring\n"
)
2009-08-05 23:34:49.432 Bug7037807[577:10b] results: (
astring,
" bstring",
" cstring",
" dstring",
" estring\n"
)



Output on Mac OS X 10.5.8

2009-08-05 23:34:49.428 Bug7037807[577:10b] results: (
astring, bstring, cstring, dstring, estring

)
2009-08-05 23:34:49.431 Bug7037807[577:10b] results: (
"astring, bstring, cstring, dstring, estring\n"
)
2009-08-05 23:34:49.432 Bug7037807[577:10b] error: XQueryError:17 -  
"invalid arguments to function - tokenize"


What does the 10.5.8 version of tokenize want as arguments? Any known  
work-around?


--
Michael

___

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

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

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

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


Re: NSMenuItem addTarget & retain

2009-08-05 Thread Graham Cox


On 04/08/2009, at 6:46 PM, Remko Tronçon wrote:


Foo* foo = [[Foo aloc] init];
NSMenuItem* item = [[NSMenuItem alloc] initWithTitle: @"Item" action:
@selector(action:) keyEquivalent: @""];
[item setTarget: foo];
[foo release];

Unless I have a problem in some other part of my code, it seems that
releasing the 'foo' object is not allowed. In my limited knowledge of
Cocoa, I would expect that NSMenuItem retains foo. Is this a wrong
assumption?



Yes, NSMenuItem does not retain its target.

From the docs: "Control objects do not (and should not) retain their  
targets. However, clients of controls sending action messages  
(applications, usually) are responsible for ensuring that their  
targets are available to receive action messages. To do this, they may  
have to retain their targets in memory-managed environments. This  
precaution applies equally to delegates and data sources."


file:///Developer/Documentation/DocSets/com.apple.ADC_Reference_Library.CoreReference.docset/Contents/Resources/Documents/documentation/Cocoa/Conceptual/CocoaFundamentals/CommunicatingWithObjects/CommunicateWithObjects.html


--Graham


___

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

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

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

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


Re: Generating random numbers

2009-08-05 Thread Mahaboob
Thanks.
It is working well.


On 8/5/09 10:24 PM, "Agha Khan"  wrote:

> Dear Mahaboob:
> Many people have answered this question but I will take this route.
> 
> First of all you only have call srandom once in you program. Best place is
> when you are going to load the object.
> 
> I defined 2 macros
> 
> #define RANDOM_SEED() srandom(time(NULL))
> #define RANDOM_INT(__MIN__, __MAX__) ((__MIN__) + random() % ((__MAX__+1) -
> (__MIN__)))
> 
> #define ARRAYSIZE 15
> 
> Now I assume that you already called RANDOM_SEDD previously.
> Now create an array with your range of your numbers. In your case 1 to 16.
> 
> int RandArray[ARRAYSIZE];
> 
> for (int i = 0; i < ARRAYSIZE; i++)
> {
> RandArray[i] = i + 1; // choose your own range
> }  
> 
> Now shuffle them
> 
> for (int i = 0; i < ARRAYSIZE; i++)
> {
> int RandomNumber = RANDOM_INT(0, ARRAYSIZE);
>   int temp = RandArray[RandomNumber];
>   RandArray[RandomNumber] = RandArray[i];
>   RandArray[i] = temp
> }
> 
> :-)
> Agha
> 
> On Aug 5, 2009, at 3:44 AM, Mahaboob wrote:
> 
>> I need to produce 15 random numbers between 1 to 16 without repeating any
>> number. I used the code like
>> 
>> int i,j;
>> for(i=0;i<15;i++){
>> j =random() % 15 +1;
>> NSLog(@"No: %d => %d \n",i,j);
>> srandom(time(NULL)+i);
>> }
>> But some numbers are repeating.
>> How can I do it without repeating the numbers?
>> 
>> Thanks in advance
>> Mahaboob
>> 
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>> 
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/cocoa-dev/agha.khan%40me.com
>> 
>> This email sent to agha.k...@me.com
> 
> 


___

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

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

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

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


Re: adding a sub menu to multiple super menus?

2009-08-05 Thread Graham Cox


On 06/08/2009, at 5:41 AM, David M. Cotter wrote:

in carbon, you can have a sub menu that is used in more than one  
super menu.


is there a trick to get this to go in Cocoa?  otherwise i'm stuck  
with cloning and managing all the clones (eg: if i enable a menu  
item, or if i change the key shortcut, or change the item text, i  
have to find all the clones and perform the same op on them too,  
it's a real pain)



As far as I know a menu has to be a distinct instance - you can't  
share them. I think I tried it once and it failed miserably.


However, the second part of your statement suggests that you are not  
managing your menus in the most efficient way. There's no need to go  
through all your menus and set them up in a particular way - just wait  
for the menu to be used and then validate it. It doesn't matter which  
menu is being validated, you just look at the individual item and set  
it up on the fly. This is done using the NSMenuValidation protocol,  
and its sole method, -validateMenuItem: Normally this is done to  
enable and check/uncheck a menu item but it is also free to change the  
title, key equivalent, etc. usually the only thing that needs to  
remain constant is the item's action, which is its "identity" in the  
sense that that's what the menu item does.


--Graham


___

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

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

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

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


Re: Using NSTimer and CGEventPost causes problems

2009-08-05 Thread Quincey Morris

On Aug 4, 2009, at 06:51, Björn Bollensdorff wrote:

I'm trying to implement a remote control for an application. The  
mouse data is send to the application through a socket which is  
checked regularly by a function triggered by a NSTimer. The data is  
then transfered into the corresponding CGEvent. Interestingly this  
works as long as I do not perform a mouse down on a NSButton or  
something similar. If I hit an active element the NSTimer does not  
fire anymore.
I simplified the problem as much as possible getting to the  
following small application that does not use socket communication  
anymore.
There are two buttons, a checkbox and a label. The first button  
triggers the mouse event and the second is the target. The checkbox  
sets the position of the mouseEvent. If it is unchecked the mouse  
down and up are performed somewhere in the applications window. If  
it is checked they are performed on the target button. To see if the  
action bound to the target button was triggered the label changes.
If the first button is activated I generate a CGEvent MouseDown and  
start a NSTimer. The NSTimer triggers a function that generates a  
CGEvent MouseUp. The behavior of the small application now depends  
on where the MouseDown is performed. If there is no element  
underneath it, the NSTimer fires and the Mouse Up is performed. If  
an element is hit the NSTimer does not fire until I manually hit the  
mouse button.


I'm using CGEventCreateMouseEvent to create the MouseEvent and  
CGEventPost to post the mouse event. I tried CGPostMouseEvent, too,  
getting the same result.


Does anybody know how to can resolve that problem?


You're going to have to come up with a different solution, something  
that doesn't depend on a NSTimer.


The problem is that it's perfectly legal for something (e.g. a  
NSButton responding to a mouse-down) to use a local, modal event loop  
-- a "while" loop, not a NSRunLoop -- using  
nextEventMatchingMask:untilDate:inMode:dequeue: to get the events it's  
interested in, and during that loop timers won't run. Depending on the  
mode, it may also be that some event types are left in the queue, or  
unknown events may even be discarded (not likely by NSButton, but in  
the general case), so you can't even assume network communications  
will continue, and you can't come up with a solution involving custom  
event types.


I suspect you'll have a similar problem with dragging scroll bars, and  
perhaps with selecting things in controls.



___

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

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

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

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


Re: IB connections - newbie question

2009-08-05 Thread Greg Guerin

Oftenwrong Soong wrote:

I am making a NSDocument based app. In the NIB for the document  
window, I need to create a connection to a "global" data object  
(think singleton). This "global" data is used when creating the  
document, but isn't part of the document.


Normally I'd make a connection by dragging a NSObject into the NIB  
but that would instantiate a separate object for each open  
document. I want all open document(s) to share the same object.


How can I create such a connection between the NIB and my code?



Create a class, every instance of which refers to the singleton.   
These instances all act like funnels leading to the same place.  No  
matter which instance you refer to in any nib, nor how many instances  
are instantiated, it ultimately all goes to the singleton.


  -- GG

___

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

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

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

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


Re: Design Question

2009-08-05 Thread Quincey Morris

On Aug 4, 2009, at 11:35, Kaelten wrote:


I have an application I'm working on where I'm using mainly Bindings
for communicating with the UI, but I find myself in situations where
I'm not getting all the data updates to the UI.

These lack of updates seem to stem either from dependent keys, loose
coupling between objects, to-many relationships, and nullable
relationships.

I work around the first one mostly with
setKeys:triggerChangeNotificationsForDependentKey: (I'm targeting
10.4).

It's the other three cases that I'm having a slight issue with.  One
thought I had is that I could craft notifications so that the loosely
coupled objects and nullable relationships can listen for something
that'd cause them to need to update.


It's all about KVO compliance. If you update your data model KVO- 
compliantly, then its observers (e.g. the user interface) will notice  
the changes.


The documentation isn't very clear, but the "granularity" of KVO  
compliance isn't obvious. An *object* (an instance) is KVO-compliant  
for a *property* (a string name) or its not. Typically, all objects of  
a class have the same KVO-compliance for their properties, due their  
shared class implementation, so it's reasonable to talk about the KVO  
compliance of a class for a given property. If you have a lot of  
properties, you have a lot of compliance issues to deal with.


So, it's not an issue of loose couplings, or to-many relationships or  
nullable relationships -- they'll all work fine if the corresponding  
properties are updated KVO-compliantly, and that has to be taken on a  
case-by-case basis. Sorry.


If you want ask specifically about certain of the malfunctioning  
properties, you might get answers you can adapt to the others. I just  
don't think there's a general answer, except that it really does work,  
if you Do It Right(tm).



___

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

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

Help/Unsubscribe/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 NSTimer and CGEventPost causes problems

2009-08-05 Thread Adam R. Maxwell


On Aug 5, 2009, at 10:24 PM, Quincey Morris wrote:

The problem is that it's perfectly legal for something (e.g. a  
NSButton responding to a mouse-down) to use a local, modal event  
loop -- a "while" loop, not a NSRunLoop -- using  
nextEventMatchingMask:untilDate:inMode:dequeue: to get the events  
it's interested in, and during that loop timers won't run.


How about scheduling the timer to fire in NSEventTrackingRunLoopMode  
using -[NSRunLoop addTimer:forMode:]?  I'm not sure how that interacts  
with the CGEvent stuff, but it might be worth a try.






smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Two right buttons on UINavigationBar?

2009-08-05 Thread Agha Khan

Hi:
I have a UINavigationBar where I would like to place 2 buttons. I was  
looking UINavigationBar.h for its implementation and didn't see the  
way we could add more than 2 buttons(Right hand side and left hand  
siderightBarButtonItem ) but my both buttons are rightBarButtonsItems  
where one of them is always hidden. I need 2 buttons because they  
point to 2 different click functions and different captions.



You might have better idea?

Best regards
Agha 
___


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

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

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

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


Re: GC and NSCFType finalize

2009-08-05 Thread Quincey Morris

On Aug 4, 2009, at 18:12, dp wrote:

I recently updated some older code and converted to GC in the  
process. Most of the time, things run fine. But every now and then I  
seem to run into a CFRelease and/or a finalize down in system  
libraries or Apple Frameworks. The ImageIO framework and  
CFDateFormatter seem to be the culprits in some cases. How do I best  
go about debugging these and/or working around them? Are these bugs  
in the frameworks or just a GC issue I need to do something about?  
Crash stacks below.



Thread 1 Crashed:
0   com.apple.ImageIO.framework   	0x0396c6e4  
jp2_family_src::close() + 10
1   com.apple.ImageIO.framework   	0x0396c67a  
_cg_JP2TearDownDecompressor + 28
2   com.apple.ImageIO.framework   	0x0396c64f JP2ReleaseInfoCallback  
+ 21
3   com.apple.Foundation  	0x01a95a81 -[NSCFType finalize] +  
49

4   libobjc.A.dylib 0x0087c6b6 finalizeOneObject + 56


What's the actual crash? Was it an exception? A signal? You should  
check in the console log to see if there's any useful information there.


If an object is being finalized at the time of the crash, it's likely  
you're failing to keep a strong reference to an object that you're  
responsible for keeping alive. For example, something that was  
previously being kept alive long enough by an autorelease (without any  
explicit reference in your stack, global or instance variables) could  
now be collected much earlier.


It's also possible that something that was thread-safe before (or  
whose thread safety didn't matter) is now unsafe because of the  
garbage collector thread.



___

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

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

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

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


Re: NSOutlineView Not Updating After Adding Items

2009-08-05 Thread Quincey Morris

On Aug 5, 2009, at 13:33, Mark Szymczyk wrote:

I'm using NSOutlineView and NSTreeController to display and edit an  
NSXMLDocument on Mac OS X 10.5. The application uses bindings and is  
based on the "Using Tree Controllers with NSXML Objects" example in  
the Tree-Based XML Programming Guide. I get some strange behavior  
when I add elements to the XML document.


If the parent has not been expanded in the outline view when I add a  
new element to it, the outline view behaves properly. When I expand  
the parent in the outline view I can see the new element has been  
added. Once I expand the parent, a problem arises. Any new elements  
I add to that parent do not appear in the outline view. Collapsing  
the parent in the outline view and resizing the window do not help.  
The elements get added to the XML tree. They're just not getting  
added to the outline view. I know the elements are being added to  
the XML tree because saving the document, closing it, and reopening  
it makes the added elements appear in the outline view.


I have tried calling the outline view's reloadData method and the  
tree controller's rearrangeObjects method. I have also tried calling  
the outline view's reloadItem:reloadChildren method, but the outline  
view still not does not update after expanding a parent element in  
the outline view. What do I have to do to get the outline view to  
display the proper information?


How are you "adding elements to the XML document"? If you're calling  
add... methods on the NSXML... objects, you'd expect the sort of  
results you're seeing -- AFAIK the proxy tree maintained by the  
NSTreeController has no way of knowing that you changed the underlying  
data model, since AFAIK KVO is not in operation for the tree  
structure. Did you try constructing the NSXML... objects you want to  
add, then tell the NSTreeController to add them?



___

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

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

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

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


Re: Core Data completely unable to find the source object model for migration

2009-08-05 Thread Daniel DeCovnick
I had this exact problem. I did exactly what he did, and to continue  
this, yes, I did create a mapping model. Never got it to work, but I  
had a user base of 1 and a database of about 10 objects at the time,  
so I just abandoned attempting migration entirely and recreated the DB  
with the new model by hand. If there's a solution, I'd love to hear  
about it.


That said, I did learn a couple of things in the attempts. First, as  
long as there was a second data model and mapping model in the  
project, that error would occur, regardless of which model was set as  
the current version. Also, attempting to set the the current model  
would occasionally cause Xcode to report an internal error, and  
afterwards (even through relaunching Xcode), setting the current model  
version would do nothing (the check mark wouldn't move) unless I  
deleted both references and re-added them to the project. This leads  
me to believe that it's an Xcode bug, but I don't see how it can be if  
almost no one is running into this. Are there only two people in the  
world migrating data?


-Daniel

On Aug 5, 2009, at 9:06 AM, mmalc Crawford wrote:



On Aug 4, 2009, at 11:20 PM, Matteo Manferdini wrote:


I created a mapping model and
called addPersistentStoreWithType:configuration:URL:options:error:
with the NSMigratePersistentStoresAutomaticallyOption option.


Did you create a mapping model?
If not, did you specify the NSInferMappingModelAutomaticallyOption  
option?


NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
   [NSNumber numberWithBool:YES],  
NSMigratePersistentStoresAutomaticallyOption,
   [NSNumber numberWithBool:YES],  
NSInferMappingModelAutomaticallyOption, nil];


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