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
the file that I need the users information in already has a , so Is there a way that I can get the users location coordinates without using the CLLocationManagerDelegate thing?
Ok, I really spend 2 days on this and it has gotten me stumped.
From my main UIViewController I called a WebViewController which is a UIViewController with a UIWebView inside:
UOLCategoriesWebViewController *ucwvcontroller = [[UOLCategoriesWebViewController alloc] initWithNibName:@"UOLCategoriesWebViewController" bundle:nil];
[self presentModalViewController:ucwvcontroller animated:YES];
[ucwvcontroller release];
Inside the UOLCategoriesWebViewController I've call the delegate method shouldStartLoadWithRequest where when the user clicks on a particular type of link it parses out the params and return back to the main UIViewController (or at least that's what I want it to do):
- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {
BOOL continueOrExit = YES;
NSURL *url = request.URL;
NSString *urlString = [url relativeString];
NSString *urlParams = [url query];
NSArray *urlParamArr = [urlParams componentsSeparatedByString:@"&"];
NSLog(@"the url is: %@",urlString);
//NSLog(@"the params are: %@,%@",[urlParamArr objectAtIndex:0],[urlParamArr objectAtIndex:1]);
//BOOL endTrain1 = [[urlParamArr objectAtIndex:1] hasPrefix:@"subCatValue"];
//BOOL endTrain2 = ([urlParamArr objectAtIndex:1
//NSLog(@"Number of elements: %@",[urlParamArr count]);
if (navigationType == UIWebViewNavigationTypeLinkClicked)
{
//NSLog(@"Enter into His glory");
if ([urlString hasSuffix:@"categories_list.php"]) {
//NSLog(@"2nd Heaven");
continueOrExit = YES;
}else if ([[urlParamArr objectAtIndex:1] hasPrefix:@"subCatValue"]) {
continueOrExit = NO;
NSLog(@"end of the train");
NSArray *firstParamStringArr = [[urlParamArr objectAtIndex:0] componentsSeparatedByString:@"="];
NSArray *secondParamStringArr = [[urlParamArr objectAtIndex:1] componentsSeparatedByString:@"="];
NSString *catSelected = [firstParamStringArr objectAtIndex:1];
NSString *subCatSelected = [secondParamStringArr objectAtIndex:1];
//go back to native app
[self goBackToMain:catSelected andSubCat:subCatSelected];
}
}
return continueOrExit;
}
Actually in the above function where I am calling the goBackToMain method I want it to call the delegate method and return to the mainviewcontroller. Unfortunately after executing that goBackToMain method it goes back to this method and continue to return continueOrExit.
Is there anyway to make it truly exit without returning anything? I've tried putting in multiple returns to no avail. Or can I in the html page pass some javascript to directly call this method so that I don't have to go through this delegate method?
Thanks for the help in advance!
I was running myapp on an iPod touch and I noticed it missed some libraries. Is that the reason?
[Session started at 2010-03-19 15:57:04 +0800.]
GNU gdb 6.3.50-20050815 (Apple version gdb-1128) (Fri Dec 18 10:08:53 UTC 2009)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "--host=i386-apple-darwin --target=arm-apple-darwin".tty /dev/ttys007
Loading program into debugger…
Program loaded.
target remote-mobile /tmp/.XcodeGDBRemote-237-78
Switching to remote-macosx protocol
mem 0x1000 0x3fffffff cache
mem 0x40000000 0xffffffff none
mem 0x00000000 0x0fff none
run
Running…
[Switching to thread 11779]
[Switching to thread 11779]
sharedlibrary apply-load-rules all
(gdb) continue
warning: Unable to read symbols for "/Library/MobileSubstrate/MobileSubstrate.dylib" (file not found).
2010-03-19 15:57:18.892 myapp[2338:207] MS:Notice: Installing: com.yourcompany.myapp [myapp] (478.52)
2010-03-19 15:57:19.145 myapp[2338:207] MS:Notice: Loading: /Library/MobileSubstrate/DynamicLibraries/Backgrounder.dylib
warning: Unable to read symbols for "/Library/MobileSubstrate/DynamicLibraries/Backgrounder.dylib" (file not found).
warning: Unable to read symbols for "/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.2.sdk/usr/lib/libsubstrate.dylib" (file not found).
MS:Warning: message not found [myappAppDelegate applicationWillResignActive:]
MS:Warning: message not found [myappAppDelegate applicationDidBecomeActive:]
2010-03-19 15:57:19.550 myapp[2338:207] in FirstViewController
2010-03-19 15:57:20.344 myapp[2338:207] in load table view
2010-03-19 15:57:20.478 myapp[2338:207] in loading splash view
2010-03-19 15:57:22.793 myapp[2338:207] in set interface
Program received signal: “0”.
warning: check_safe_call: could not restore current frame
I have only a little question:
Why the CFPreferences-API creates multiple files in my UserPrefs-Directory? All the files have my Bundle-Identifier as name and all (except the one, the original) have added a suffix like this:
com.myComp.myApp.plist <- (only this plist-file should be created)
com.myComp.myApp.plist.0qzcicc
com.myComp.myApp.plist.8dhjfht
I am trying to create a UIImageView called theImageView in the touchesBegan method that I can then then move to a new location in touchesMoved. Currently I am receiving an "undeclared" error in touchesMoved where I set the new location for theImageView.
What can I do to keep theImageView in memory between these two methods?
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
...
UIImageView *theImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image.png"]];
theImageView.frame = CGRectMake(263, 228, 193, 300);
[theImageView retain];
...
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
...
theImageView.frame = CGRectMake(300, 300, 193, 300);
...
}
I have a MKPinAnnotationView that the user can drag around the map.
It is very difficult for a user to drag the pin. I've tried increasing the frame size and also using a giant custom image. But nothing seems to actually change the hit area for the drag to be larger than default.
Consequently, I have to attempt to tap/drag about ten times before anything happens.
MKPinAnnotationView *annView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"bluedot"] autorelease];
UIImage *image = [UIImage imageNamed:@"blue_dot.png"];
annView.image = image;
annView.draggable = YES;
annView.selected = YES;
return annView;
What am I missing here?
Sorry for the multitude of iPhone Programming newb questions but..
what is the reason for having an unsigned type for something such as
- (unsigned)count
for the NSArray class.
Why not just define it as
- (int)count
?
Hi everyone,
I'm working on a cocoa app for syncing data between two folders.
It have profiles (so you can have multiple setups)
It's possible to analyze data
It's possible to sync the data
Im a little confused. First of all i cant really see where to have a model? And how many controller would you suggest? 1 WindowController or AnalyzeController, SyncController etc.
Its quite a while since i have worked with MVC. I've read some articles but i'm missing concrete examples on how to divide it.
Best regards.
When the return button on the keyboard for a textfield is tapped I want to add a UIView, then connect to a website with NSURlConnection sendsynchronousrequest and I have the code in that order
But when I run in the simulator (I can't run on device) the connection is run first then the subview is added (ie the opposite of the order of the code)
Why is this and how can stop it, because I want the view to added, then the connection done and then the view removed.
How would I go about adding an opaque logo to the background of a simple scrollview with text on it? I want the logo to stay still while the text scrolls.
It is the code:
self.view.backgroundColor= [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"yourimage.png"]];
My "yourimage.png" have some space that is transparency. But it shows me it becomes black. How can I change it to show the transparency instead of black color? thz.
I have some problem when i work with UIImagePickerController .when I presentModalViewController,and the picker pops up right,but i can not select a picture! when i touch on the picture list, the list can only scroll up and down,but can not select!
how about this? thanks.
Can anyone enlighten me as to the differences between the two statements below.
[self playButtonSound];
AND:
[self performSelector:@selector(playButtonSound)];
I am just asking as I had some old code that used @selector, now with a little more knowledge I can't think why I did not use [self playButtonSound] instead, they both seem to do the same as written here.
gary
I have made a navigation based application in my rootview controller i have put a text view when i run the app i am able to see that text view but when i navigate on other xib and comes back i am not able to see that text view if i do it programmatically by using view for header than i am able to c that text but why i am not able to do it in design time
any idea
how does one use code to do this:
produce 15 random numbers that are not in any order, and that only occur once
eg.
1 4, 2, 5, 3, 6, 8, 7, 9, 10, 13, 12, 15, 14, 11
rand() or arc4rand() can repeat some, which is not what im after.
Thanks
Can I separate merged model into source parts? Need to do it for reason of upgrade to new versions my every or not every source part of db. It must work under 10.5, so i cant use inferredMappingModelForSourceModel.
how do i access GData api's(get map) in my application ?
hey i tryed to add gdata.framework in my iphone application but it generate error and tell me in iphone how can i use this web service?
Hello, I have app which have two views implemented in Tabbar, one of them is UIWebView which shows some random html and second is mapView (route-me map), I have function in MapViewController.m which do sth stuff when is clicked on marker label
- (void) tapOnLabelForMarker: (RMMarker*) marker onMap: (RMMapView*) map {
NSLog(@"taponlabelformarker clicked");
self.tabBarController.selectedIndex=0;
WebViewController *web = [[WebViewController alloc] init];
[web dajdasepije];
}
and that function should call function which show html in uiwebview tab
-(void)dajdasepije {
NSLog(@" pokreni me njezno");
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.com"]]];
}
Problem is that UIWebView never show google page that I asked for it,
NSLog prints out at terminal messages that function was called but nothing else happens.
Please help, Thanks in advance.
Marjan
Hi, i wrote the following code :
NSString *table = [[NSString alloc]initWithString:@"<table>"] ;
for (NSDictionary *row in rows)
{
table = [table stringByAppendingString:@"<tr>"];
NSArray *cells = [row objectForKey:@"cells"];
for (NSString *cell in cells){
table = [table stringByAppendingString:@"<td>"];
table = [table stringByAppendingString:cell];
table = [table stringByAppendingString:@"</td>"];
}
table = [table stringByAppendingString:@"</tr>"];
index++;
}
table = [table stringByAppendingString:@"</table>"];
return [table autorelease];
the rows are json response parsed by jsonlib
this string is returned to a viewcontroller that loads it into a webview ,but i keep getting exc_bad_access for this code on completion of the method that calls it , i don't even have to load it to the webview just calling this method and not using the nsstring causes the error on completion of the calling method... any help will be apperciated thanks .
Hi!
I'm trying to do that for a couple of days now, and after reading tons of messages of people trying to do that too, I'm still unable to have a fully working UITextField in some of my UITableViewCells, just like in this example: http://img231.imageshack.us/img231/4858/picture4za3.png
Either I have the form working but the text is not visible (although I set its color to blue), the keyboard goes on the field when I click on it and I haven't been able to correctly implement the keyboard events.
I tried with a bunch of examples from Apple (mainly UICatalog, where there is a kinda similar control) but it's still not working correctly.
Can somebody help me (and all the people trying to realize this control) and post a simple implementation of a UITextField in a UITableViewCell, that works fine?
Thank you very much.
I'm trying to do an animation where when a person clicks from point A to Point B on screen the object should slowly slide straight across (horizontally) from point A to Point B. I tried doing a for loop with something like:
for (CGFloat i=previousPoint.x; i <= newPoint.x; i++){
[UIView animateWithDuration:10
delay:0
options:nil
animations:^ {
[magnifier removeFromSuperview];
magnifier = [[MagnifierView alloc] init];
CGPoint np = {i, newPoint.y};
magnifier.viewToMagnify = imageView;
magnifier.touchPoint = np;
[imageView addSubview:magnifier];
[magnifier setNeedsDisplay];
}
completion:^(BOOL finished) {
}];
}
but for some reason it is moving it way up and then eventually to point B. sort of in a weird curve.
how can I do this correctly?
Hi,
I created four language files for my app: two for the preferences and two for the strings. I added them into Xcode and it works great on the phone but the string files are shown as "Localizable.strings (de)" and "Localizable.strings (en)", while I have two files called "Root.plist" under the "Settings.bundle" in the groups "de.lproj" and "en.lproj" (see screenshot).When I don't add the two "Root.plist" files instead of "Settings.bundle", I get what I want ("Root.plist (de)" and "Root.plist (en)") but I have no "Settings.bundle" in Xcode. Is somebody out there who can help me to a get what I want?
Using the build and analyze of XCode I saw i have a memory leak in my code:
- (NSString *) doIt
{
NSString *var = [[NSString alloc] init];
return var;
}
This is of course a simplified snippet of my problem
where do i release the object?