Search Results

Search found 113 results on 5 pages for 'nsthread'.

Page 2/5 | < Previous Page | 1 2 3 4 5  | Next Page >

  • iPhone: One Object, One Thread

    - by GingerBreadMane
    On the iPhone, I would like to do some operations on an image in a separate thread. Rather than dealing with semiphores, locking, etc., I'd like to use the 'One Object, One Thread' method of safely writing this concurrent operation. I'm not sure what is the correct way to copy my object into a new thread so that the object is not accessed in the main thread. Do I use the 'copy' method? If so, do I do this before the thread or inside the thread? ... -(void)someMethod{ UIImage *myImage; [NSThread detachNewThreadSelector:@selector(getRotatedImage:) toTarget:self withObject:myImage]; } -(void)getRotatedImage:(UIImage *)image{ ... ... UIImage *copiedImage = [image copy]; ... ... }

    Read the article

  • Accessing Instance Attributes from Secondary Thread (iPhone-SDK)

    - by Travis
    I have a class with an NSDictionary attribute. Inside this class I dispatch another thread to handle NSXMLParser handling. Inside my -didStartElement, I access the dictionary in the class (to compare an element found in the XML to one in the dictionary). At this point I get undefined results. Using NSLog (I'm not advanced in XCode debugging), I see that it bombs around access of the NSDictionary. I tried just iterating the dictionary and dumping the key/values inside the didStartElement and this bombs at different keys each time. The only thing I can conclude is that something is not kosher that I'm doing with regards to accessing main thread attributes from the secondary thread. I'm somewhat new to multithreading and am not sure what the best protocol is safely access attributes from additional threads. Thanks all.

    Read the article

  • How can i get a list of currently running threads in objective-C(iphone)

    - by krasnyk
    Is there a way to get the list of currently running threads in objective-C? I'm mostly interested in getting the NSThreads objects, cause i want to replace the assertion handler for each running thread? If such thing is not possible, maybe i could set my own selector to be invoked after any thread is spawn(so that i could do the assertion handler replacement over there)?

    Read the article

  • xmlCtxtGetLastError - Iphone

    - by Raphael Kohn
    Hi, I have been programming with NSXMLParser for quite a while and lately, I came out with this error. The strangiest thing is that it only happens in debug mode. Once I load the App in Simulator and run it from Simulator (without Xcode involved), it runs fine. The code is very straight foward, it is a simple XML parsing whose contents were loaded from the web in a separated thread. Does anybody have alredy encoutered that error?? Thanks in advance.

    Read the article

  • Strategy for animating a lot of "LED's" - thread?, UIView animations? NSOperation? (iPhone)

    - by RickiG
    Hi I have to do some different views containing 72 LED lights. I built an LED Class so I can loop through the LED's and set them to different colors (Green, Red, Orange, Blue None etc.). The LED then loads the appropriate .png. This works fine, I loop over the LED's and set them. Now I know that at some time they will need to not just turn on/off change color, but will have to turn on with a small delay. Like an equalizer. I have a 5-10 views containing the 72 LED's and I would like to achieve the above with the minimum amount of memory/CPU strain. for(LED *l in self.ledArray) { [l display:Green]; } I simply loop as shown above and inside the LED is a switch case that does the correct logic. If this were actual LED's and a microController I would use sleep(100) or similar in the loop, but I would really like to avoid stuff like that for obvious reasons. I was thinking that doing a performOnThread withDelay would really be consuming, so would UIView animation changing the alpha and NSOperation would also be a lot of lifting for a small feature. Is there a both efficient and clever way to go around this? Thanks for any inspiration given:)

    Read the article

  • IconDownloader, problem with lazy downloading

    - by Junior B.
    My problem is simple to be described but it seems to be hard to solve. The problem is loading icons, with a custom class like IconDownloader.m provided by an official example from Apple, avoiding crashes if I release the view. I've added the IconDownloader class to my app, but it's clear that this approach is good only if the tableview is the root. The big problem is when the view is not the root one. F.e: if I start to scroll my second view (the app now load the icons) and, without leaving it the time to finish the download, I go back to root, the app crash because the view that have to be updated with new icons doesn't exist anymore. One possible solution could be implement an OperationQueue in the view, but with this approach I've to stop the queue when I change the view and restart it when I come back and the idea to have N queues don't make me enthusiastic. Anyone found a good solution for this problem?

    Read the article

  • When we should use NSThreads in a cocoa Touch ?

    - by srikanth rongali
    I am writing a small game by using cocos2d. It is a shooting game. Player on one side and enemy on other side. To run the both actions of player shooting and enemy shooting do we should use threads ? Or can we do without using them. At present I am not using threads. But I can manage to do both actions of player and enemy at same time. Should I use threads compulsory good performance ? Or am I doing wrong without using threads ? Please help me from this confusion. Thank you.

    Read the article

  • very strange thread error message

    - by John Smith
    I an trying to put a method in a separate thread in the background. It nearly works except that occasionally I get a lot of error messages with the message METHODCLOSURE: OH NO SEPERATE THREAD with the bad spelling and all. Does anyone know what this means?

    Read the article

  • What is wrong with my @synchronized block?

    - by hyn
    I have 2 threads in my application, a game update thread and render/IO/main thread. My update thread updates the game state, and the render thread renders the scene based on the updated values of the game state models and a few other variables stored inside an object (gameEngine). The render thread gets executed while the game thread is still updating, which is a problem, so it appeared to me the solution is to use @synchronized like this: @synchronized(gameEngine) { [gameEngine update]; nextUpdate = now + GAME_UPDATE_INTERVAL; gameEngine.lastGameUpdateInterval = now - lastUpdate; gameEngine.lastGameUpdateTime = now; lastUpdate = now; } But the render thread still accesses the gameEngine object between -update and the last 3 lines of the block. Why is this?

    Read the article

  • Method invoked but not returning anything

    - by or azran
    i am calling this method from a touch in UITableViewCell , -(void)PassTitleandiMageByindex:(NSString *)number{ NSLog(@"index : %d",number.intValue); NSArray *objectsinDictionary = [[[NSArray alloc]init]autorelease]; objectsinDictionary = [[DataManeger sharedInstance].sortedArray objectAtIndex:number.intValue]; if ([objectsinDictionary count] > 3) { ProductLabel = [objectsinDictionary objectAtIndex:3]; globaliMageRef = [objectsinDictionary objectAtIndex:2]; [self performSegueWithIdentifier:@"infoseg" sender:self]; }else{ mQid = [objectsinDictionary objectAtIndex:1]; globaliMageRef = [objectsinDictionary objectAtIndex:2]; [mIQEngines Result:mQid]; NSLog(@"mQid : %@ Global : %@",mQid,globaliMageRef); }} Problem:- i am trying to get the same functionality programmatically by calling [self PassTitleandiMageByindex:stringNumber]; when i am calling this programmatically i can see the debug log getting in the place it should be, but nothing happens (by pressing the UITableViewCellon the screen) here is how it turns on by touch, - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ [tableView deselectRowAtIndexPath:indexPath animated:YES]; NSString *st = [NSString stringWithFormat:@"%d",[indexPath row]]; [self PassTitleandiMageByindex:st];} I have also tried to call the table-view delegate by :[[Tview delegate] tableView:Tview didSelectRowAtIndexPath:selectedCellIndexPath]; but, nothing happened.

    Read the article

  • Strategy for animation a lot of LED's - thread?, UIView animations? NSOperation? (iPhone)

    - by RickiG
    Hi I have to do some different views containing 72 LED lights. I built an LED Class so I can loop through the LED's and set them to different colors (Green, Red, Orange, Blue None etc.). The LED then loads the appropriate .png. This works fine, I loop over the LED's and set them. Now I know that at some time they will need to not just turn on/off change color, but will have to turn on with a small delay. Like an equalizer. I have a 5-10 views containing the 72 LED's and I would like to achieve the above with the minimum amount of memory/CPU strain. for(LED *l in self.ledArray) { [l display:Green]; } I simply loop as shown above and inside the LED is a switch case that does the correct logic. If this were actual LED's and a microController I would use sleep(100) or similar in the loop, but I would really like to avoid stuff like that for obvious reasons. I was thinking that doing a performOnThread withDelay would really be consuming, so would UIView animation changing the alpha and NSOperation would also be a lot of lifting for a small feature. Is there a both efficient and clever way to go around this? Thanks for any inspiration given:)

    Read the article

  • When I really need to use [NSThread sleepForTimeInterval:1];

    - by Timbo
    Hi there, I have a program that needs to use sleep. Like really needs to. In lieu of spending ages explaining why, suffice to say that it needs it. Now I'm told to split off my code into a separate thread if it requires sleep so I don't lose interface responsiveness, so I've started learning how to use NSThread. I've created a brand new program that is conceptual so to solve the issue for this example will help me in my real program. Short story is I have a class, it has instance variables and I need a loop with a sleep to be depended on the value of that instance variable. Here's what I've put together anyway, your help is very much appreciated :) Cheers Tim /// Start Test1ViewController.h /// #import <UIKit/UIKit.h> @interface Test1ViewController : UIViewController { UILabel* label; } @property (assign) IBOutlet UILabel *label; @end /// End Test1ViewController.h /// /// Start Test1ViewController.m /// #import "Test1ViewController.h" #import "MyClass.h" @implementation Test1ViewController @synthesize label; - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; label.text = @"1"; [NSThread detachNewThreadSelector:@selector(backgroundProcess) toTarget:self withObject:nil]; } - (void)backgroundProcess { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; // Create an instance of a class that will eventually store a whole load of variables MyClass *aMyClassInstance = [MyClass new]; [aMyClassInstance createMyClassInstance:(@"Timbo")]; while (aMyClassInstance.myVariable--) { NSLog(@"blah = %i",aMyClassInstance.myVariable); label.text = [NSString stringWithFormat:@"blah = %d", aMyClassInstance.myVariable]; //how do I pass the new value out to the updateLabel method, or reference aMyClassInstance.myVariable? [self performSelectorOnMainThread:@selector(updateLabel) withObject:nil waitUntilDone:NO]; //the sleeping of the thread is absolutely mandatory and must be worked around. The whole point of using NSThread is so I can have sleeps [NSThread sleepForTimeInterval:1]; } [pool release]; } - (void)updateLabel {label.text = [NSString stringWithFormat:@"blah = %d", aMyClassInstance.myVariable]; // be nice if i could } - (void)didReceiveMemoryWarning {[super didReceiveMemoryWarning];} - (void)viewDidUnload {} - (void)dealloc {[super dealloc];} @end /// End Test1ViewController.m /// /// Start MyClass.h /// #import <Foundation/Foundation.h> @interface MyClass : NSObject { NSString* name; int myVariable; } @property int myVariable; @property (assign) NSString *name; - (void) createMyClassInstance: (NSString*)withName; - (int) changeVariable: (int)toAmount; @end /// End MyClass.h /// /// Start MyClass.h /// #import "MyClass.h" @implementation MyClass @synthesize name, myVariable; - (void) createMyClassInstance: (NSString*)withName{ name = withName; myVariable = 10; } - (int) changeVariable: (int)toAmount{ myVariable = toAmount; return toAmount; } @end /// End MyClass.h ///

    Read the article

  • iPhone: how to use performSelector:onThread:withObject:waitUntilDone: method?

    - by Michael Kessler
    Hi all, I am trying to use a separate thread for working with some API. The problem is that I am not able to use performSelector:onThread:withObject:waitUntilDone: method with a thread that I' instantiated for this. My code: @interface MyObject : NSObject { NSThread *_myThread; } @property(nonatomic, retain) NSThread *myThread; @end @implementation MyObject @synthesize myThread = _myThread; - (NSThread *)myThread { if (_myThread == nil) { NSThread *myThreadTemp = [[NSThread alloc] init]; [myThreadTemp start]; self. myThread = myThreadTemp; [myThreadTemp release]; } return _myThread; } - (id)init { if (self = [super init]) { [self performSelector:@selector(privateInit:) onThread:[self myThread] withObject:nil waitUntilDone:NO]; } return self; } - (void)privateInit:(id)object { NSLog(@"MyObject - privateInit start"); } - (void)dealloc { [_myThread release]; _myThread = nil; [super dealloc]; } @end "MyObject - privateInit start" is never printed. What am I missing? I tried to instantiate the thread with target and selector, tried to wait for method execution completion (waitUntilDone:YES). Nothing helps. UPDATE: I don't need this multithreading for separating costly operations to another thread. In this case I could use the performSelectorInBackground as mentioned in few answers. The main reason for this separate thread is the need to perform all the actions in the API (TTS by Loquendo) from one single thread. Meaning that I have to create an instance of the TTS object and call methods on that object from the same thread all the time.

    Read the article

  • How to I pass @selector as a parameter?

    - by erotsppa
    For the method [NSThread detachNewThreadSelector:@selector(method:) toTarget:self withObject:(id)SELECTOR]; How do I pass in a @selector? I tried casting it to (id) to make it compile but it crashes in runtime. More specifically, I have a method like this +(void)method1:(SEL)selector{ [NSThread detachNewThreadSelector:@selector(method2:) toTarget:self withObject:selector]; } it crashes, how do I pass in the selector without crashing? So that the new thread can call the selector when the thread is ready?

    Read the article

  • Core Data managed object context thread synchronisation

    - by Ben Reeves
    I'm have an issue where i'm updating a many-to-many relationship in a background thread, which works fine in that threa, but when I send the object back to the main thread the changes do not show. If I close the app and reopen the data is saved fine and the changes show on the main thread. Also using [context lock] instead of a different managed object context works fine. I have tried NSManagedObjectContext: - (BOOL)save:(NSError **)error; - (void)refreshObject:(NSManagedObject *)object mergeChanges:(BOOL)flag; at different stages throughout the process but it doesn't seem to help. My core data code uses the following getter to ensure any operations are thread safe: - (NSManagedObjectContext *) managedObjectContext { NSThread * thisThread = [NSThread currentThread]; if (thisThread == [NSThread mainThread]) { //Main thread just return default context return managedObjectContext; } else { //Thread safe trickery NSManagedObjectContext * threadManagedObjectContext = [[thisThread threadDictionary] objectForKey:CONTEXT_KEY]; if (threadManagedObjectContext == nil) { threadManagedObjectContext = [[[NSManagedObjectContext alloc] init] autorelease]; [threadManagedObjectContext setPersistentStoreCoordinator: [self persistentStoreCoordinator]]; [[thisThread threadDictionary] setObject:threadManagedObjectContext forKey:CONTEXT_KEY]; } return threadManagedObjectContext; } } and when I pass object between threads i'm using -(NSManagedObject*)makeSafe:(NSManagedObject*)object { if ([object managedObjectContext] != [self managedObjectContext]) { NSError * error = nil; object = [[self managedObjectContext] existingObjectWithID:[object objectID] error:&error]; if (error) { NSLog(@"Error makeSafe: %@", error); } } return object; } Any help appreciated

    Read the article

  • UIView removeFromSuperView animation delay

    - by Mike
    I have a method which animates one of the subviews of UIWindow and then removes it from UIWindow using removeFromSuperview. But when I put removeFromSuperview after animation block, the animation never shows, because removeFromSuperview removes the UIView from UIWindow before the animation plays :-( How can I delay removeFromSuperview so the animation plays first, and then subview is removed? I tried [NSThread sleepForTimeInterval:1]; after animation block but that didn't have desired effect, because animation sleeps too for some reason. My code for this method: - (void) animateAndRemove { NSObject *mainWindow = [[UIApplication sharedApplication] keyWindow]; [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:0.8]; UIView *theView = nil; for (UIView *currentView in [mainWindow subviews]) { if (currentView.tag == 666) { currentView.backgroundColor = [UIColor colorWithRed:0.8 green:0.8 blue:0.8 alpha:0.0]; theView = currentView; } } [UIView setAnimationTransition: UIViewAnimationTransitionNone forView:theView cache:YES]; [UIView commitAnimations]; //[NSThread sleepForTimeInterval:1]; [theView removeFromSuperview]; }

    Read the article

  • Thread and two dimensional array in objective C?

    - by mactonny
    Hey, guys, I am just starting to wrap my head around objective C and I am doing a little project on Iphone. And I just encountered a weird problem. I had to deal with images in my program so I have a lot local variables declared like temp[width][height]. If I am not using NSThread to perform image processing, it works all fine. However, if I use NSThread, it'll keep giving me EXC_BAD_ACCESS on whenever I try to access a 2-D array declared like temp[widht][height]. So I have to allocate memory from heap in order to have a 2-D array. That'll solve the problem but I still don't get it. My first thought would be stack over flow, but it worked all fine with one thread. I just don't get it.

    Read the article

  • converting NSTimer running not on main runloop to GCD

    - by Justin Galzic
    I have a task that runs periodically and it was originally designed to run on a separate run loop than the main runloop using NSThread and NSTimer. What's the best way to adapt this to take advantage of GCD? Current code: -(void)initiateSomeTask { [NSThread detachNewThreadSelector:@selector(startTimerTask) toTarget:self withObject:nil]; } -(void)startTimerTask { // We won't get back the main runloop since we're on a new thread NSRunLoop *myRunLoop = [NSRunLoop currentRunLoop]; NSPort *myPort = [NSMachPort port]; [myRunLoop addPort:myPort forMode:NSDefaultRunLoopMode]; NSTimer *myTimer = [NSTimer timerWithTimeInterval:10 /* seconds */ target:self selector:@selector(doMyTaskMethod) userInfo:nil repeats:YES]; [myRunLoop addTimer:myTimer forMode:NSRunLoopCommonModes]; [myRunLoop run]; } Is there anything I can do besides replace detachNewThreadSelector with dispatch_async?

    Read the article

  • Problem in creating another thread

    - by Avinash
    Hi, I am using NSThread to create different thread and displaying images in my application on a new thread instead of main thread. On main thread i am working with a table view which is displaying data from XML file, In the same view I am displaying images below. But, displaying images on new thread is not working properly. Did i made any mistake in creating Here below is my code. Please help me its urgent. Thanks in advance...................... - (void)viewDidLoad { [super viewDidLoad]; [NSThread detachNewThreadSelector:@selector(startTheBackgroundJob) toTarget:self withObject:nil]; } - (void)startTheBackgroundJob { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; currentLocationImageView = [[UIImageView alloc] init]; NSArray *images = [NSArray arrayWithObjects:img1, img2, nil]; [currentLocationImageView setAnimationImages:images]; [currentLocationImageView setAnimationRepeatCount:0]; [currentLocationImageView setAnimationDuration:5.0]; [self.view addSubview:currentLocationImageView]; [pool release]; }

    Read the article

  • passing variables when calling methon in new thread (iphone)

    - by Mouhamad Lamaa
    dear stacks i need to pass variables to the thread method when creating a new thread my code is the follwing //generating thread [NSThread detachNewThreadSelector:@selector(startThread) toTarget:self withObject:nil]; thread job - (void)startThread:(NSInteger *)var img:(UIImageView *) Img{ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [NSThread sleepForTimeInterval:var]; [self performSelectorOnMainThread:@selector(threadMethod) withObject:nil waitUntilDone:NO]; //i need to pass Img to threadMethod: [pool release]; } thread Method - (void)threadMethod:(UIImageView *) Img { //do some coding. } so how i can do this (pass parameter to both of methods

    Read the article

  • Xcodebuild throws assert failures after successful build?

    - by Derek Clarkson
    Hi all, I'me getting the following after building from he command line using xcodebuild, ay ideas what might be wrong? ** BUILD SUCCEEDED ** 2010-06-06 20:20:12.916 xcodebuild[8267:80b] [MT] ASSERTION FAILURE in /SourceCache/DevToolsBase/DevToolsBase-1648/pbxcore/Target.subproj/PBXTarget.m:597 Details: Assertion failed: (nil == _buildContext) || (nil == [_buildContext target]) Object: <PBXLegacyTarget:0x104b97370> Method: -dealloc Thread: <NSThread: 0x100b141a0>{name = (null), num = 1} Backtrace: 0 0x000000010035feaf -[XCAssertionHandler handleFailureInMethod:object:fileName:lineNumber:messageFormat:arguments:] (in DevToolsCore) 1 0x000000010035fc1a _XCAssertionFailureHandler (in DevToolsCore) 2 0x00000001002790d1 -[PBXTarget dealloc] (in DevToolsCore) 3 0x00000001002911e8 -[PBXLegacyTarget dealloc] (in DevToolsCore) 4 0x00000001002c5b16 -[PBXTargetBookmark dealloc] (in DevToolsCore) 5 0x00007fff8224ff71 __CFBasicHashStandardCallback (in CoreFoundation) 6 0x00007fff82250931 __CFBasicHashDrain (in CoreFoundation) 7 0x00007fff822396b3 _CFRelease (in CoreFoundation) 8 0x0000000100254171 -[PBXProject dealloc] (in DevToolsCore) 9 0x00007fff82262d56 _CFAutoreleasePoolPop (in CoreFoundation) 10 0x00007fff841b530c -[NSAutoreleasePool drain] (in Foundation) 11 0x000000010000c60d 12 0x00000001000014f4 ** INTERNAL ERROR: Uncaught Exception ** Exception: ASSERTION FAILURE in /SourceCache/DevToolsBase/DevToolsBase-1648/pbxcore/Target.subproj/PBXTarget.m:597 Details: Assertion failed: (nil == _buildContext) || (nil == [_buildContext target]) Object: <PBXLegacyTarget:0x104b97370> Method: -dealloc Thread: <NSThread: 0x100b141a0>{name = (null), num = 1} Backtrace: 0 0x000000010035feaf -[XCAssertionHandler handleFailureInMethod:object:fileName:lineNumber:messageFormat:arguments:] (in DevToolsCore) 1 0x000000010035fc1a _XCAssertionFailureHandler (in DevToolsCore) 2 0x00000001002790d1 -[PBXTarget dealloc] (in DevToolsCore) 3 0x00000001002911e8 -[PBXLegacyTarget dealloc] (in DevToolsCore) 4 0x00000001002c5b16 -[PBXTargetBookmark dealloc] (in DevToolsCore) 5 0x00007fff8224ff71 __CFBasicHashStandardCallback (in CoreFoundation) 6 0x00007fff82250931 __CFBasicHashDrain (in CoreFoundation) 7 0x00007fff822396b3 _CFRelease (in CoreFoundation) 8 0x0000000100254171 -[PBXProject dealloc] (in DevToolsCore) 9 0x00007fff82262d56 _CFAutoreleasePoolPop (in CoreFoundation) 10 0x00007fff841b530c -[NSAutoreleasePool drain] (in Foundation) 11 0x000000010000c60d 12 0x00000001000014f4 Stack: 0 0x00007fff822ded06 __exceptionPreprocess (in CoreFoundation) 1 0x00007fff832470f3 objc_exception_throw (in libobjc.A.dylib) 2 0x00007fff823369b9 -[NSException raise] (in CoreFoundation) 3 0x000000010035ff6a -[XCAssertionHandler handleFailureInMethod:object:fileName:lineNumber:messageFormat:arguments:] (in DevToolsCore) 4 0x000000010035fc1a _XCAssertionFailureHandler (in DevToolsCore) 5 0x00000001002790d1 -[PBXTarget dealloc] (in DevToolsCore) 6 0x00000001002911e8 -[PBXLegacyTarget dealloc] (in DevToolsCore) 7 0x00000001002c5b16 -[PBXTargetBookmark dealloc] (in DevToolsCore) 8 0x00007fff8224ff71 __CFBasicHashStandardCallback (in CoreFoundation) 9 0x00007fff82250931 __CFBasicHashDrain (in CoreFoundation) 10 0x00007fff822396b3 _CFRelease (in CoreFoundation) 11 0x0000000100254171 -[PBXProject dealloc] (in DevToolsCore) 12 0x00007fff82262d56 _CFAutoreleasePoolPop (in CoreFoundation) 13 0x00007fff841b530c -[NSAutoreleasePool drain] (in Foundation) 14 0x000000010000c60d 15 0x00000001000014f4 Abort trap

    Read the article

  • Memory leak at Autorelease pool in Iphone sdk

    - by monish
    Hi guys, I am getting leak at [pool release]; My code here is: #pragma mark UISearchBarDelegate delegate methods - (void)performSearch:(UISearchBar *)aSearchBar { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; artistName= [aSearchBar.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; if ([artistName length] > 0) { [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; LyricsAppDelegate* appDelegate = (LyricsAppDelegate*) [ [UIApplication sharedApplication] delegate]; artistsList=[appDelegate doSearch:artistName ]; [theTableView reloadData]; [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; [aSearchBar resignFirstResponder]; } else { [aSearchBar resignFirstResponder]; } [NSThread exit]; [pool release]; } - (void)searchBarSearchButtonClicked:(UISearchBar *)aSearchBar { @try { [NSThread detachNewThreadSelector:@selector(performSearch:) toTarget:self withObject:aSearchBar]; [aSearchBar resignFirstResponder]; } @catch (NSException * e) { NSLog(@"\n caught an exception"); } @finally { } } Here I am getting leak at [pool release]; in performSearch method. How can I solve this. Anyone's help will be much appreciated. Thank you, Monish.

    Read the article

  • [Cocoa] Placing an NSTimer in a separate thread

    - by ndg
    I'm trying to setup an NSTimer in a separate thread so that it continues to fire when users interact with the UI of my application. This seems to work, but Leaks reports a number of issues - and I believe I've narrowed it down to my timer code. Currently what's happening is that updateTimer tries to access an NSArrayController (timersController) which is bound to an NSTableView in my applications interface. From there, I grab the first selected row and alter its timeSpent column. From reading around, I believe what I should be trying to do is execute the updateTimer function on the main thread, rather than in my timers secondary thread. I'm posting here in the hopes that someone with more experience can tell me if that's the only thing I'm doing wrong. Having read Apple's documentation on Threading, I've found it an overwhelmingly large subject area. NSThread *timerThread = [[[NSThread alloc] initWithTarget:self selector:@selector(startTimerThread) object:nil] autorelease]; [timerThread start]; -(void)startTimerThread { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; activeTimer = [[NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(updateTimer:) userInfo:nil repeats:YES] retain]; [runLoop run]; [pool release]; } -(void)updateTimer:(NSTimer *)timer { NSArray *selectedTimers = [timersController selectedObjects]; id selectedTimer = [selectedTimers objectAtIndex:0]; NSNumber *currentTimeSpent = [selectedTimer timeSpent]; [selectedTimer setValue:[NSNumber numberWithInt:[currentTimeSpent intValue]+1] forKey:@"timeSpent"]; } -(void)stopTimer { [activeTimer invalidate]; [activeTimer release]; }

    Read the article

  • how to slove error when using thread?

    - by ChandreshKanetiya
    I have following error msg in console when using NSThread "Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now..." I have submit my sample code here - (void)viewDidLoad { appDeleg = (NewAshley_MedisonAppDelegate *)[[UIApplication sharedApplication] delegate]; [[self tblView1] setRowHeight:80.0]; [super viewDidLoad]; self.title = @"Under Ground"; [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; [NSThread detachNewThreadSelector:@selector(CallParser) toTarget:self withObject:nil]; } -(void)CallParser { Parsing *parsing = [[Parsing alloc] init]; [parsing DownloadAndParseUnderground]; [parsing release]; [self Update_View]; //[myIndicator stopAnimating]; [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; } here "DownloadAndParseUnderground" is the method of downloding data from the rss feed and -(void) Update_View{ [self.tblView1 reloadData]; } when Update_View method is called the tableView reload Data and in the cellForRowAtIndexPath create error and not display custom cell - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; CustomTableviewCell *cell = (CustomTableviewCell *) [tblView1 dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { [[NSBundle mainBundle] loadNibNamed:@"customCell" owner:self options:nil]; cell = objCustCell; objCustCell = nil; }

    Read the article

< Previous Page | 1 2 3 4 5  | Next Page >