Proxy settings in UIWebview or at application level

2012-04-26 Thread Vikas Mahajan
Hi,

I am currently working on making an iOS browser which will have
provision to set proxy in it. I am making browser as wrapper around
UIWebview. But as NSURL / NSREQUEST doesn't support setting proxy, so
I got struck here. I know that we can set proxy in CFURL, so is there
any way we can capture packets send by UIWebview at CFNetwork level
inside our application to route them through proxy server?
Or does Cocoa supports reflection to set proxy dynamically inside
application sandbox?
Any other way by which we can set proxy in UIWebview or at application level?
Please help.


-- 
Thanks,

Vikas Mahajan
P.S.: I don't want to use ASIHTTPRequest because it has a lot of
limitations, so please suggest some different method.
___

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

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

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

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


Re: DataSource modified while TableView is displaying data

2012-04-26 Thread Peter Hudson

Can you post your code for numberOfRowsInTableView:

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: DataSource modified while TableView is displaying data

2012-04-26 Thread Jean Suisse
Dear Peter,

Thank you for your reply. Here is the requested code (see below). 
After more investigations, I would like to take back a previous statement, that 
the tableview was perfectly aware that the number of rows in the DS was 
changed. This is due to my inexperience in stepping through the code across 
multiple threads.

Here are the facts :

- Only the controller removes rows from the datasource. Either in response to 
user actions (canceling tasks) or as a result of a Task completed notification 
from a running task.
- Each change in the dataSource is immediately followed by a reloadData message 
sent to the TableView.
- Sometimes, randomly, the TableView requests a row index that is out of bounds 
by one index (e.g. row #5 when the dataSource contains only 5 elements).

I am thinking that a redraw occurs in-between the removal of one element of the 
table and the reloadData message. 
For now, I did a quick fix for this issue by adding a category with 
"safeObjectAtIndex"…. But one way to be certain would be to ensure that the two 
messages (removal + reloadData) are sent without any thread/process switching 
occurring…

The code for numberOfRowsInTableView : (experimentList is an instance of 
NSMutableAray)

- (NSInteger)numberOfRowsInTableView:(NSTableView*)tableView
{   
return self.experimentList ? [self.experimentList count] : 0;
}

Jean


On 26 avr. 2012, at 11:45, Peter Hudson wrote:

> 
> Can you post your code for numberOfRowsInTableView:
> 
> 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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: DataSource modified while TableView is displaying data

2012-04-26 Thread Peter Hudson
I've had a similar problem to this in the past.  I never bottomed it out. 

The workaround I used was to check validity of the row index for every data 
call and, if the index was invalid, return a 
suitable easily visible debug string ( "bad index") and post a timed update 
0.25 second later.

I never saw my debug string and the code ran happily.

Peter


On 26 Apr 2012, at 11:23, Jean Suisse  wrote:

> Dear Peter,
> 
> Thank you for your reply. Here is the requested code (see below). 
> After more investigations, I would like to take back a previous statement, 
> that the tableview was perfectly aware that the number of rows in the DS was 
> changed. This is due to my inexperience in stepping through the code across 
> multiple threads.
> 
> Here are the facts :
> 
> - Only the controller removes rows from the datasource. Either in response to 
> user actions (canceling tasks) or as a result of a Task completed 
> notification from a running task.
> - Each change in the dataSource is immediately followed by a reloadData 
> message sent to the TableView.
> - Sometimes, randomly, the TableView requests a row index that is out of 
> bounds by one index (e.g. row #5 when the dataSource contains only 5 
> elements).
> 
> I am thinking that a redraw occurs in-between the removal of one element of 
> the table and the reloadData message. 
> For now, I did a quick fix for this issue by adding a category with 
> "safeObjectAtIndex"…. But one way to be certain would be to ensure that the 
> two messages (removal + reloadData) are sent without any thread/process 
> switching occurring…
> 
> The code for numberOfRowsInTableView : (experimentList is an instance of 
> NSMutableAray)
> 
> - (NSInteger)numberOfRowsInTableView:(NSTableView*)tableView
> {
>return self.experimentList ? [self.experimentList count] : 0;
> }
> 
> Jean
> 
> 
> On 26 avr. 2012, at 11:45, Peter Hudson wrote:
> 
>> 
>> Can you post your code for numberOfRowsInTableView:
>> 
>> 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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: DataSource modified while TableView is displaying data

2012-04-26 Thread Roland King
how about using @synchronize to avoid it 

On Apr 26, 2012, at 6:23 PM, Jean Suisse wrote:

> Dear Peter,
> 
> Thank you for your reply. Here is the requested code (see below). 
> After more investigations, I would like to take back a previous statement, 
> that the tableview was perfectly aware that the number of rows in the DS was 
> changed. This is due to my inexperience in stepping through the code across 
> multiple threads.
> 
> Here are the facts :
> 
> - Only the controller removes rows from the datasource. Either in response to 
> user actions (canceling tasks) or as a result of a Task completed 
> notification from a running task.
> - Each change in the dataSource is immediately followed by a reloadData 
> message sent to the TableView.
> - Sometimes, randomly, the TableView requests a row index that is out of 
> bounds by one index (e.g. row #5 when the dataSource contains only 5 
> elements).
> 
> I am thinking that a redraw occurs in-between the removal of one element of 
> the table and the reloadData message. 
> For now, I did a quick fix for this issue by adding a category with 
> "safeObjectAtIndex"…. But one way to be certain would be to ensure that the 
> two messages (removal + reloadData) are sent without any thread/process 
> switching occurring…
> 
> The code for numberOfRowsInTableView : (experimentList is an instance of 
> NSMutableAray)
> 
> - (NSInteger)numberOfRowsInTableView:(NSTableView*)tableView
> { 
>   return self.experimentList ? [self.experimentList count] : 0;
> }
> 
> Jean
> 
> 
> On 26 avr. 2012, at 11:45, Peter Hudson wrote:
> 
>> 
>> Can you post your code for numberOfRowsInTableView:
>> 
>> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/rols%40rols.org
> 
> This email sent to r...@rols.org


___

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

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

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

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

RE: removeFromSuperview problem

2012-04-26 Thread Jim Adams
I wonder if you should move that removeFromSuperview back onto the main thread? 
I know when I was doing lots of cross language stuff with java in the past that 
that was usually my problem.

Jim Adams

-Original Message-
From: cocoa-dev-bounces+jim.adams=sas@lists.apple.com 
[mailto:cocoa-dev-bounces+jim.adams=sas@lists.apple.com] On Behalf Of 
Leanne Attard
Sent: Thursday, April 26, 2012 2:49 AM
To: cocoa-dev@lists.apple.com
Subject: removeFromSuperview problem

Problem explanation:

I am doing a Java application which calls a JNI Library to draw using OpenGL on 
the window created by JAVA, using the JAWT NSView handle given as in example:  
http://developer.apple.com/library/mac/#samplecode/JAWTExample/Introduction/Intro.html,
 and then adding a customized NSView to the NSView given, as a subview.

When a window is resized to a smaller size the JAVA side of my code  calls a 
native function in my library to remove the native subview added earlier.  This 
is when the application stalls (Not Responding). Upon forcing the application 
to quit, a crash report pops up part of which is shown
below.  As far as I can  understand this, there is a deadlock.  This happens 
upon calling removeFromSuperview method in NSView.   This is called
on a different thread than the one in which the subview was added.  Can this be 
the issue causing the problem?  Any help is greatly appreciated.
Can this function be called on a different thread than the one on which 
'addsubview' was called?


  Thread 3f1b6
  User stack:
19 thread_start + 13 (in libSystem.B.dylib) [0x7fff850a5e89]
  19 _pthread_start + 331 (in libSystem.B.dylib) [0x7fff850a5fd6]
19 jio_snprintf + 35946 (in libclient64.dylib) [0x10100d244]
  19 JVM_StartThread + 1362 (in libclient64.dylib) [0x1010b0cf5]
19 JVM_StartThread + 1853 (in libclient64.dylib) [0x1010b0ee0]
  19 JVM_StartThread + 2203 (in libclient64.dylib) [0x1010b103e]
19 JVM_StartThread + 2299 (in libclient64.dylib) [0x1010b109e]
  19 JVM_StartThread + 2565 (in libclient64.dylib) [0x1010b11a8]
19 JVM_Lseek + 193197 (in libclient64.dylib) [0x1010a511e]
  19 ??? [0x104001438]
19 ??? [0x10400685a]
  19 ??? [0x10400685a]
19 ??? [0x10400685a]
  19 ??? [0x10400685a]
19 ??? [0x104006a82]
  19 ??? [0x10400685a]
19 ??? [0x104006e8d]
  19 ??? [0x1040069b3]
19 ??? [0x104011d6e]
  19 JVM_DoPrivileged + 93 (in 
libjvmlinkage.dylib) [0x1000961ad]
19 JVM_DoPrivileged + 560 (in 
libclient64.dylib) [0x1010b03b5]
  19 JVM_Lseek + 192625 (in 
libclient64.dylib) [0x1010a4ee2]
19 JVM_Lseek + 193197 (in 
libclient64.dylib) [0x1010a511e]
  19 ??? [0x104001438]
19 ??? [0x1040069b3]
  19 ??? [0x10400685a]
19 ??? [0x10400685a]
  19 ??? [0x104006d34]
19 ??? [0x10400685a]
  19 ??? 
[0x104006d34]
19 ??? 
[0x10400685a]
  19 ??? 
[0x10400685a]
19 ??? 
[0x10400685a]
  19 ??? 
[0x10400685a]
19 ??? 
[0x10400685a]
  19 
??? [0x10400685a]
19 
??? [0x10400685a]
  
19 ??? [0x10400685a]

19 ??? [0x10400685a]

  19 ??? [0x10400685a]

19 ??? [0x10400685a]

  19 ??? [0x10400685a]

19 ??? [0x104006a82]
 

RE: removeFromSuperview problem

2012-04-26 Thread Leanne Attard
Thanks for replying,
to tell you the truth I thought of this before the post and i tried using

[view performSelectorOnMainThread:@selector(remove_view:) withObject:nil 
waitUntilDone:YES];

where remove_view method calls 'removefromsuperview' however the application 
still came to a Not Responding state.

--- On Thu, 4/26/12, Jim Adams  wrote:

> From: Jim Adams 
> Subject: RE: removeFromSuperview problem
> To: "Leanne Attard" , "cocoa-dev@lists.apple.com" 
> 
> Date: Thursday, April 26, 2012, 1:24 PM
> I wonder if you should move that
> removeFromSuperview back onto the main thread? I know when I
> was doing lots of cross language stuff with java in the past
> that that was usually my problem.
> 
> Jim Adams
> 
> -Original Message-
> From: cocoa-dev-bounces+jim.adams=sas@lists.apple.com
> [mailto:cocoa-dev-bounces+jim.adams=sas@lists.apple.com]
> On Behalf Of Leanne Attard
> Sent: Thursday, April 26, 2012 2:49 AM
> To: cocoa-dev@lists.apple.com
> Subject: removeFromSuperview problem
> 
> Problem explanation:
> 
> I am doing a Java application which calls a JNI Library to
> draw using OpenGL on the window created by JAVA, using the
> JAWT NSView handle given as in example:  
> http://developer.apple.com/library/mac/#samplecode/JAWTExample/Introduction/Intro.html,
> and then adding a customized NSView to the NSView given, as
> a subview.
> 
> When a window is resized to a smaller size the JAVA side of
> my code  calls a native function in my library to
> remove the native subview added earlier.  This is when
> the application stalls (Not Responding). Upon forcing the
> application to quit, a crash report pops up part of which is
> shown
> below.  As far as I can  understand this, there is
> a deadlock.  This happens upon calling
> removeFromSuperview method in NSView.   This
> is called
> on a different thread than the one in which the subview was
> added.  Can this be the issue causing the
> problem?  Any help is greatly appreciated.
> Can this function be called on a different thread than the
> one on which 'addsubview' was called?
> 
> 
>   Thread 3f1b6
>   User stack:
>     19 thread_start + 13 (in libSystem.B.dylib)
> [0x7fff850a5e89]
>       19 _pthread_start + 331 (in
> libSystem.B.dylib) [0x7fff850a5fd6]
>         19 jio_snprintf + 35946 (in
> libclient64.dylib) [0x10100d244]
>           19 JVM_StartThread + 1362
> (in libclient64.dylib) [0x1010b0cf5]
>             19 JVM_StartThread
> + 1853 (in libclient64.dylib) [0x1010b0ee0]
>               19
> JVM_StartThread + 2203 (in libclient64.dylib) [0x1010b103e]
>                 19
> JVM_StartThread + 2299 (in libclient64.dylib) [0x1010b109e]
>                
>   19 JVM_StartThread + 2565 (in libclient64.dylib)
> [0x1010b11a8]
>                
>     19 JVM_Lseek + 193197 (in libclient64.dylib)
> [0x1010a511e]
>                
>       19 ??? [0x104001438]
>                
>         19 ??? [0x10400685a]
>                
>           19 ??? [0x10400685a]
>                
>             19 ???
> [0x10400685a]
>                
>               19 ???
> [0x10400685a]
>                
>                 19
> ??? [0x104006a82]
>                
>                
>   19 ??? [0x10400685a]
>                
>                
>     19 ??? [0x104006e8d]
>                
>                
>       19 ??? [0x1040069b3]
>                
>                
>         19 ??? [0x104011d6e]
>                
>                
>           19 JVM_DoPrivileged + 93
> (in libjvmlinkage.dylib) [0x1000961ad]
>                
>                
>             19
> JVM_DoPrivileged + 560 (in libclient64.dylib) [0x1010b03b5]
>                
>                
>               19
> JVM_Lseek + 192625 (in libclient64.dylib) [0x1010a4ee2]
>                
>                
>                 19
> JVM_Lseek + 193197 (in libclient64.dylib) [0x1010a511e]
>                
>                
>                
>   19 ??? [0x104001438]
>                
>                
>                
>     19 ??? [0x1040069b3]
>                
>                
>                
>       19 ??? [0x10400685a]
>                
>                
>                
>         19 ??? [0x10400685a]
>                
>                
>                
>           19 ??? [0x104006d34]
>                
>                
>                
>             19 ???
> [0x10400685a]
>                
>                
>                
>               19 ???
> [0x104006d34]
>                
>                
>                
>                 19
> ??? [0x10400685a]
>                
>                
>                
>                
>   19 ??? [0x10400685a]
>                
>                
>                
>                
>     19 ??? [0x10400685a]
>                
>                
>                
>                
>       19 ??? [0x10400685a]
>                
>                
>                
>                
>         19 ??? [0x10400685a]
>                
>                
>    

CALayer compositingFilter trouble

2012-04-26 Thread Markus Spoettl

Hello,

  I'm posting this here because quartz-dev seems dead. I have a layer 
hosting view where I use a -compositingFilter with a CIColorBlendMode 
filter (default settings). It's constructed and applied to the layer 
like this:


CIFilter *cf = [CIFilter filterWithName:@"CIColorBlendMode"];
[cf setDefaults];
[overlayLayer setCompositingFilter:cf];

overlayLayer is z-ordered above another layer that has a grayscale 
content (a height field). I draw colors into the overlayLayer which in 
turn colorizes the height field. Works fine but some colors give me 
grieve in that the hue is completely wrong and I have no idea why.


To illustrate the problem I've uploaded an annotated screenshot here:

http://www.shiftoption.com/temp/blendingtrouble.png

It shows both the colors used (upper rect) and blended result (lower 
rect). The upper screen shot is for two colors that "work". The lower is 
for a color that doesn't (color C). The difference between the two is 
saturation, 0.1 works, 0.003 doesn't (in case you wonder, 0.004 works).


So, these work:
[NSColor colorWithCalibratedHue:0.55 saturation:0.1 brightness:1.0 
alpha:1.0]

[NSColor colorWithCalibratedHue:1.0 saturation:0.8 brightness:0.8 alpha:1.0]

This one doesn't:
[NSColor colorWithCalibratedHue:0.55 saturation:0.003 brightness:1.0 
alpha:1.0]


I don't have the slightest idea why the hue changes so dramatically. 
Maybe this is to be expected? Why? Can I avoid that? How?


Any tips greatly appreciated!

Regards
Markus
--
__
Markus Spoettl
___

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

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

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

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


Re: CALayer compositingFilter trouble

2012-04-26 Thread David Duncan
On Apr 26, 2012, at 9:12 AM, Markus Spoettl wrote:

>  I'm posting this here because quartz-dev seems dead.

Quartz-Dev may be quiet, but it doesn't seem dead to me :).

> It shows both the colors used (upper rect) and blended result (lower rect). 
> The upper screen shot is for two colors that "work". The lower is for a color 
> that doesn't (color C). The difference between the two is saturation, 0.1 
> works, 0.003 doesn't (in case you wonder, 0.004 works).
> 
> So, these work:
> [NSColor colorWithCalibratedHue:0.55 saturation:0.1 brightness:1.0 alpha:1.0]
> [NSColor colorWithCalibratedHue:1.0 saturation:0.8 brightness:0.8 alpha:1.0]
> 
> This one doesn't:
> [NSColor colorWithCalibratedHue:0.55 saturation:0.003 brightness:1.0 
> alpha:1.0]
> 
> I don't have the slightest idea why the hue changes so dramatically. Maybe 
> this is to be expected? Why? Can I avoid that? How?


My best guess would be you are underflowing. 1/255 = ~0.0039. 0.004 * 255 = 1, 
0.003 * 255 = 0. Since the saturation determines how much of the hue 
contributes to the final color, if it is 0 you end up with a grayscale color 
based on brightness.
--
David Duncan


___

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

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

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

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


Re: CALayer compositingFilter trouble

2012-04-26 Thread Markus Spoettl

On 4/26/12 6:50 PM, David Duncan wrote:

On Apr 26, 2012, at 9:12 AM, Markus Spoettl wrote:


I'm posting this here because quartz-dev seems dead.


Quartz-Dev may be quiet, but it doesn't seem dead to me :).


OK, my bad, I'm subscribed but I didn't realize there is actually a bit 
of traffic. I'll take it there (with your response).


Sorry for the wrong list.

Regards
Markus
--
__
Markus Spoettl
___

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

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

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

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


SMJobBless

2012-04-26 Thread Jeremy Matthews
Does anyone out there use SMJobBless to interact with the Mac OS X to 
create/destroy, and load/unload launchdamons/agents?
Really looking for sample code to make sure I'm doing things 
correctly...sometimes my jobs go wonky.

Apple docs have not been updated in about 2 years time...

Thanks,
jeremy
___

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

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

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

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


Using Instruments to profile UITableView drawing

2012-04-26 Thread Marco Tabini
I wonder if someone could point me to the right way to profile 
poorly-performing custom-drawn UITableView cells. I've come across this problem 
several times, and usually manage to figure out how to solve it, but my process 
is not very scientific—there's far too much trial and error involved, and I 
wonder whether there isn't a known way to pinpoint exactly which part of the 
code causes a table to stutter using Instruments. I've tried Googling for the 
problem, but it seems to me that the vast majority of people giving suggestions 
are focusing on known techniques to make table cells perform, rather than 
trying to understand where an already-implemented table is going astray.

Thanks!


—Mt.
___

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

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

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

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

Re: Using Instruments to profile UITableView drawing

2012-04-26 Thread Mikkel Islay

On 26 Apr 2012, at 20:37, Marco Tabini wrote:

> I wonder if someone could point me to the right way to profile 
> poorly-performing custom-drawn UITableView cells. I've come across this 
> problem several times, and usually manage to figure out how to solve it, but 
> my process is not very scientific—there's far too much trial and error 
> involved, and I wonder whether there isn't a known way to pinpoint exactly 
> which part of the code causes a table to stutter using Instruments. I've 
> tried Googling for the problem, but it seems to me that the vast majority of 
> people giving suggestions are focusing on known techniques to make table 
> cells perform, rather than trying to understand where an already-implemented 
> table is going astray.

If you haven't done it already, the first thing to try is running  your app 
through the Time Profiler.

Mikkel


___

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

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

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

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

Re: Using Instruments to profile UITableView drawing

2012-04-26 Thread Tito Ciuro
Hello,

I would also profile it with the Core Animation instrument. Make sure you 
select the "Color Blended Layers" checkbox in the Debug Options area. This will 
apply a colored overlay to each view (green is opaque and red is transparent.)

-- Tito

On Apr 26, 2012, at 11:59 AM, Mikkel Islay wrote:

> 
> On 26 Apr 2012, at 20:37, Marco Tabini wrote:
> 
>> I wonder if someone could point me to the right way to profile 
>> poorly-performing custom-drawn UITableView cells. I've come across this 
>> problem several times, and usually manage to figure out how to solve it, but 
>> my process is not very scientific—there's far too much trial and error 
>> involved, and I wonder whether there isn't a known way to pinpoint exactly 
>> which part of the code causes a table to stutter using Instruments. I've 
>> tried Googling for the problem, but it seems to me that the vast majority of 
>> people giving suggestions are focusing on known techniques to make table 
>> cells perform, rather than trying to understand where an already-implemented 
>> table is going astray.
> 
> If you haven't done it already, the first thing to try is running  your app 
> through the Time Profiler.
> 
> Mikkel
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/tciuro%40mac.com
> 
> This email sent to tci...@mac.com


___

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

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

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

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

Re: DataSource modified while TableView is displaying data

2012-04-26 Thread Corbin Dunn

On Apr 26, 2012, at 3:23 AM, Jean Suisse  wrote:

> Dear Peter,
> 
> Thank you for your reply. Here is the requested code (see below). 
> After more investigations, I would like to take back a previous statement, 
> that the tableview was perfectly aware that the number of rows in the DS was 
> changed. This is due to my inexperience in stepping through the code across 
> multiple threads.
> 
> Here are the facts :
> 
> - Only the controller removes rows from the datasource. Either in response to 
> user actions (canceling tasks) or as a result of a Task completed 
> notification from a running task.
> - Each change in the dataSource is immediately followed by a reloadData 
> message sent to the TableView.
> - Sometimes, randomly, the TableView requests a row index that is out of 
> bounds by one index (e.g. row #5 when the dataSource contains only 5 
> elements).
> 
> I am thinking that a redraw occurs in-between the removal of one element of 
> the table and the reloadData message. 
> For now, I did a quick fix for this issue by adding a category with 
> "safeObjectAtIndex"…. But one way to be certain would be to ensure that the 
> two messages (removal + reloadData) are sent without any thread/process 
> switching occurring…
> 
> The code for numberOfRowsInTableView : (experimentList is an instance of 
> NSMutableAray)
> 
> - (NSInteger)numberOfRowsInTableView:(NSTableView*)tableView
> { 
>   return self.experimentList ? [self.experimentList count] : 0;
> }

This is fine as long as your experimentList is only ever modified on the main 
thread.

It sounds like that isn't the case, which is why you have random problems.

corbin


> 
> Jean
> 
> 
> On 26 avr. 2012, at 11:45, Peter Hudson wrote:
> 
>> 
>> Can you post your code for numberOfRowsInTableView:
>> 
>> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/corbind%40apple.com
> 
> This email sent to corb...@apple.com


___

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

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

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

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

Declaring Variables - Setting to nil VS Not Setting?

2012-04-26 Thread Chris Tracewell
I usually use the sample in line 1 when declaring vars inside my methods.

NSString *theString = [NSString string];
NSString *theString = nil; 
NSString *theString;

I thought lines 2 and 3 were the same thing. I was wrong. What is the 
difference and when do you use the style shown in line 3?

Thanks and pointers to docs are welcome.

--chris
___

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

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

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

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


Re: Declaring Variables - Setting to nil VS Not Setting?

2012-04-26 Thread Fritz Anderson
On 26 Apr 2012, at 3:00 PM, Chris Tracewell wrote:

> I usually use the sample in line 1 when declaring vars inside my methods.

You should be able to get this from any elementary book about C.

> NSString *theString = [NSString string];

Declares a variable containing a pointer to an NSString object, named 
theString, and fills it with an NSString pointer representing an empty string. 
The variable points to an object.

> NSString *theString = nil; 

Declares a variable containing a pointer to an NSString object, named 
theString, and fills it with zero (not a pointer to anything).

> NSString *theString;

Declares a variable containing a pointer to an NSString object, named 
theString, and doesn't fill it with anything; the variable contains whatever 
junk was left in the portion of memory the variable now uses.

— F


___

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

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

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

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

Re: Declaring Variables - Setting to nil VS Not Setting?

2012-04-26 Thread David Duncan

On Apr 26, 2012, at 1:00 PM, Chris Tracewell wrote:

> I usually use the sample in line 1 when declaring vars inside my methods.
> 
> NSString *theString = [NSString string];

If you are going to assign another value to 'theString' before you use it, then 
doing this is pointless.

> NSString *theString = nil; 
> NSString *theString;
> 
> I thought lines 2 and 3 were the same thing. I was wrong. What is the 
> difference and when do you use the style shown in line 3?

In C unless you explicitly initialize a local variable its value is undefined, 
and Objective-C inherits this behavior.

I believe however that under ARC these lines are equivalent (at least thats my 
reading of section 4.2 on initialization at 
) but given your 
comments I suspect you are not using ARC.
--
David Duncan


___

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

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

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

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


Re: SMJobBless

2012-04-26 Thread Zac Bowling
I don't know but it annoyed us at SeatMe. Apple stole our SM prefix for 
ServiceManagement.framework in 10.6 and we banged into a few classes. 

We need namespacing in Cocoa so bad.  

-- 
Zac Bowling



On Thursday, April 26, 2012 at 11:28 AM, Jeremy Matthews wrote:

> Does anyone out there use SMJobBless to interact with the Mac OS X to 
> create/destroy, and load/unload launchdamons/agents?
> Really looking for sample code to make sure I'm doing things 
> correctly...sometimes my jobs go wonky.
> 
> Apple docs have not been updated in about 2 years time...
> 
> Thanks,
> jeremy
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com 
> (mailto:Cocoa-dev@lists.apple.com))
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com 
> (http://lists.apple.com)
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/zac%40zacbowling.com
> 
> This email sent to z...@zacbowling.com (mailto:z...@zacbowling.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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Declaring Variables - Setting to nil VS Not Setting?

2012-04-26 Thread Chris Tracewell
On Apr 26, 2012, at 1:17 PM, Fritz Anderson wrote:

> You should be able to get this from any elementary book about C.

I'm sure you are correct.

>> NSString *theString = nil; 
> 
> fills it with zero (not a pointer to anything).
> 
>> NSString *theString;
> 
> and doesn't fill it with anything; the variable contains whatever junk was 
> left in the portion of memory the variable now uses.

Thank you these were excellent answers.
___

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

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

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

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


Re: Declaring Variables - Setting to nil VS Not Setting?

2012-04-26 Thread Nick Zitzmann

On Apr 26, 2012, at 2:00 PM, Chris Tracewell wrote:

> I usually use the sample in line 1 when declaring vars inside my methods.
> 
> NSString *theString = [NSString string];

Here you are creating a pointer to an empty string. This consumes memory.

> NSString *theString = nil; 

Here you are creating a null pointer. This does not consume memory. If the 
program sends a message to a null pointer, then the runtime will catch it and 
not send the message.

> NSString *theString;

Here you are declaring an uninitialized pointer. This does not consume memory, 
but attempting to message it prior to initialization will either cause a crash 
if it points to an unallocated memory address, or cause bizarre behavior if it 
points to an allocated memory address.

> when do you use the style shown in line 3?

Only when you will store something in that pointer at a later time in the 
function/method. Never read from uninitialized memory unless you **really** 
know what you're doing.

> Thanks and pointers to docs are welcome.


This is C programming language 101, so I'd recommend you read a good book on C 
programming, particularly one that deals with pointers.

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Declaring Variables - Setting to nil VS Not Setting?

2012-04-26 Thread Sean McBride
>I usually use the sample in line 1 when declaring vars inside my methods.
>
>NSString *theString = [NSString string];
>NSString *theString = nil; 
>NSString *theString;
>
>I thought lines 2 and 3 were the same thing. I was wrong. What is the
>difference and when do you use the style shown in line 3?

Fritz is spot on.  In addition, note that forms 2 and 3 are only the same under 
the ARC memory model, and is only the case for pointers to Obj-C objects.  This 
is a very new change to Obj-C.

Sean



___

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

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

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

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


Re: Declaring Variables - Setting to nil VS Not Setting?

2012-04-26 Thread Chris Tracewell
On Apr 26, 2012, at 1:20 PM, David Duncan wrote:

> In C unless you explicitly initialize a local variable its value is 
> undefined, and Objective-C inherits this behavior.

Thank you, that was what I was after.

> I believe however that under ARC these lines are equivalent (at least thats 
> my reading of section 4.2 on initialization at 
> ) but given your 
> comments I suspect you are not using ARC.

I'm using GC, still on 10.6 and XCode 3.2.6


--chris
___

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

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

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

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


Re: Question about dispatch_timer function

2012-04-26 Thread Dave Zarzycki
On Apr 25, 2012, at 6:07 PM, Kévin Vavelin  wrote:

> Hi there,
> 
> I've a question about the dispatch_timer function. I try to make a strobe 
> flash on my iPhone app and for that i used an NSTimer but a friend of mine 
> say that it's better to use dispatch function. So i was looking and try to 
> implement something. I explain my code before post anything :
> I have a UISlider in another view (settings.strobeValue) and get his value 
> for settings the timer. And i called changeStrobeState in another function 
> who wll be called by dispatch function. But when i hit the button on my view 
> and send my dispatch code, no work at all... So there is the code :
> 
> -(void)changeStrobeState
> {
>if (NO == [[NSUserDefaults standardUserDefaults] 
> boolForKey:@"buttonStrobeState"])
>{
>[deviceCapture lockForConfiguration:nil];
>[deviceCapture setTorchMode:AVCaptureTorchModeOff];
>[deviceCapture unlockForConfiguration];
>}
>else 
>{
>[deviceCapture lockForConfiguration:nil];
>[deviceCapture setTorchMode:AVCaptureTorchModeOn];
>[deviceCapture unlockForConfiguration];
>}
>BOOL state = [[NSUserDefaults standardUserDefaults] 
> boolForKey:@"buttonStrobeState"];
>[[NSUserDefaults standardUserDefaults] setBool:!state 
> forKey:@"buttonStrobeState"];
> 
> }
> 
> 
> - (dispatch_source_t)setupStrobeTimer {
>static dispatch_once_t onceToken;
>dispatch_once(&onceToken, ^{
>dispatch_queue_t queue = 
> dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
> _strobeTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 
> 0, queue);
>if (_strobeTimer) {
>dispatch_source_set_timer(_strobeTimer, 
> dispatch_walltime(DISPATCH_TIME_NOW, settings.strobeValue * NSEC_PER_SEC), 
>  settings.strobeValue * NSEC_PER_SEC, 
> 6ull * NSEC_PER_SEC);
>__block ViewController *blockSelf = self;
>dispatch_source_set_event_handler(_strobeTimer, ^{
>[blockSelf changeStrobeState];
>});

Kévin,

Your code is not calling dispatch_resume() on the timer source. Please review 
the man page and/or other documentation.

davez

>}
>});
>return _strobeTimer;
> }
> 
> Can you help me ?
> 
> Thanks for reading and sorry 'cause my english is not perfect and it's 
> actually 3 AM here :)
> 
> Cheers,
> Vavelin Kevin
> Twitter | Blog | Viadeo
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/zarzycki%40apple.com
> 
> This email sent to zarzy...@apple.com


___

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

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

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

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