Skip to main content

Posts

Showing posts from February 24, 2012

Extending an abstract class [closed]

The following code for RectangleNode extends an abstract class called GraphElement, this is needed for my program to draw rectangles where necessary. My question is regarding the abstract method in GraphElement. Rectangle Node: import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.util.ArrayList; import java.awt.Color; public class RectangleNode extends GraphElement { private double width = 20; private double length = 40; private Rectangle2D.Double rect; public RectangleNode(int x, int y) { super(x,y); rect = new Rectangle2D.Double(getXPos(), getYPos(), length, width); } public RectangleNode() { super(); rect = null; } public boolean isSelected(double x, double y) { return super(x,y); } public void draw(Graphics2D g2) { if (rect != null) g2.draw(rect); } } Graph Element: import java.awt.Graphics2D; abstract public class GraphElement { private double xPos; private double yPos; protected String label; public GraphElement() {

Multithreading in Java Help Needed

Before I go any further, this IS apart of my homework.The part that I am having trouble with however, is not the main point of the assignment. For the assignment we are just storing numbers in an array, and am adding up the elements of the array via multithreading. The user enters how many threads that they would like to run, and what the upper bound should be. For example: Upper Bound: 12 Threads: 2 The application should add up elements 1-6, then 7-12. In this case the lower bound starts out at 1 and the upper bound starts out at 6. Then the second time the loop should itterate the upper bound should be 7 and the upper bound should be 12. I am having trouble trying to devide the upper bound by the number of threads to create the increments in wich the lower and upper bounds are based off of. It is fairly simple if the number of threads devides evenly into the starting upper bound. But when It doesn't is when I am having the problem. Thank You!

What can"t I do with a Java Applet?

Consider a Java applet running in browser such as Google Chrome. What am I unable to do in the applet? Can I use Robots? Can I use ff-mpeg or Xuggle? Can I run any of the Java EE API's? There is something in Java that cannot be done inside an HTML applet - but what is it?

Generics in Java, Standard Values

Ok, so I was reading the Java online tutorial for generics and I found this: E - Element (used extensively by the Java Collections Framework) K - Key N - Number T - Type V - Value S,U,V etc. - 2nd, 3rd, 4th types I have seen a lot of methods in Java use the "E" notation but I was looking for a method that uses the "K", key notation. Anyone can help please?

One Tomcat instance for two domains and two webapps

How can I configure Tomcat (in standalone mode, that is without Apache [*]) so that I can deploy it on one server and have it serve two different webapps, depending on the domain name requested? I found a blog entry describing such a setup, but it's for Tomcat 5.5: <Engine defaultHost="domain1.com" name="Catalina"> <Host name="domain1.com" appBase="/home/user1/domain1"> <Alias>www.domain1.com</Alias> <Context path="" docBase="."/> </Host> <Host name="domain2.com" appBase="/home/user1/domain2"> <Alias>www.domain2.com</Alias> <Context path="" docBase="."/> </Host> http://iam-rakesh.blogspot.com/2009/10/hosting-multiple-domains-in-tomcat.html Also, as of now I've got one webapp, ROOT.war, inside .../tomcat/webapps/ How would that work once I'd have two "roots&quo

Trying to get the max/min in array

Im trying to get the min value in a column in the row of the max value. Im trying to using for loops but its not working. Let say a matrix A: 3 4 5 2 3 4 1 2 3 I want the program to find the max value in the [0]th row then find the min value in the colunm of the max. So result should be : max of row [0] = 5, min of column [2] = 3. I then want it to do the same of all the rows, that why I ysed a while loop. Here is the matrix: public int[][] createMatrix(int a, int b){ Scanner inputm = new Scanner(System.in); A = new int[a][b]; System.out.println("Enter elements for matrix A : "); for (int i=0 ; i < A.length ; i++){ System.out.println("Enter numbers for " + i +"th row"); for (int j=0 ; j < A[i].length ; j++){ A[i][j] = inputm.nextInt(); } } return A; } public int[][] displayMatrix(){ System.out.println("Matrix A: "); for (int i=0 ; i < A.length ; i++) { System.out.println(); for (int j=

Use content assist with Explicit type argument in Java compliance level 1.7

I'm using Eclipse 3.7 under Java 7, so I want to keep my compiler compliance level in 1.7. By the way, I'm working together with people who use Eclipse 3.6 (which one does not support compliance level 1.7). So although my JRE is JavaSE-1.7, it compiles codes with 1.6 compliance level. The problem is, because the compiler under 1.7 does not support implicit type arguments (diamond), it marks error. For example: List<String> list1 = new ArrayList<>(); // It's recommended in Java 7, but marked as error in Eclipse 3.6 So I hope to set content assist to insert explicit type arguments (old style) rather than implicit type arguments (current style). Is there a way to change how the content assist works?

How can i use a function from a Activity Class in a non-Activity Class

i have two class in my project.the first one is" public class Schtimetable extends Activity" in which there is a method i need to call in Class B :"public class ClassMode" .The method is public int calculateWeeks() { SharedPreferences preferences = getSharedPreferences("currentWeek", Context.MODE_PRIVATE); int csweek = preferences.getInt("CSweek", 1); int weekofyear = preferences.getInt("currentWeek", 0); int now_weekofyear = Calendar.getInstance().get(Calendar.WEEK_OF_YEAR); return (csweek + now_weekofyear - weekofyear);// return current week } i find i can't use it just like this: Schtimetable s = new Schtimetable(); int oddOReven = cursor.getInt(cursor.getColumnIndex("oddOReven")); cursor.close(); if ((s.calculateWeeks() % 2 == oddOReven) || (oddOReven == 2)) { Log.i(TAG, "has Class is true"); return true; } else { Log.i(TAG, "has

Guice3 Singleton is never instantiated in GAE project

I'm new to Guice and already stuck :) I pretty much copied classes GuiceConfig, OfyFactory and slightly modified Ofy from Motomapia project (which you can browse) using it as s sample. I created GuiceServletContextListener which looks like this public class GuiceConfig extends GuiceServletContextListener { static class CourierServletModule extends ServletModule { @Override protected void configureServlets() { filter("/*").through(AsyncCacheFilter.class); } } public static class CourierModule extends AbstractModule { @Override protected void configure() { // External things that don't have Guice annotations bind(AsyncCacheFilter.class).in(Singleton.class); } @Provides @RequestScoped Ofy provideOfy(OfyFactory fact) { return fact.begin(); } } @Override public void contextInitialized

data validation

I am writing a loan calculate with data validation. My maximum loan amount is 1,000,000 and I am using the method below to validate. When I enter 1,000,000 into the program it comes back with my error method. I thought (d >= max) would allow me to go up to and including my max. Can anyone see a problem with this method or is it possible I should be looking elsewhere in my code for a problem. Any help is appreciated. public static double getDoubleWithinRange(Scanner sc, String prompt, double min, double max) { double d = 0.0; boolean isValid = false; while (isValid == false) { d = getDouble (sc, prompt); if (d <= min) { System.out.println( "Error! Number must be greater than " + min + "." ); } else if (d >= max) { System.out.println("Error! Number must be less than " + max + "." ); } else isValid = tr

Render images by java code or read images from a static path?

Here's my code: 1.Java Code: public static void getImg(Long itemId) { try { Item item = Item.findById(itemId); if (item.img != null && item.img.getFile() != null{ response.setContentTypeIfNotSet(item.img.type()); renderBinary(item.img.get()); } } catch (Exception e) { Logger.error("Can't find image,itemId = " + itemId); } } html : < img src="@{{ Items.getImage(123)}}"/> 2. html : < img src="/public/images/123.jpg"/> I'm using playframework and the samples from documentation display images via the first version. What's the different (deep into mechanism) between them, especially in response performance ?

How do I call a method of a generic type in a collection which is guaranteed to exist?

I have been using generics for sometime, but only in a simple straightforward fashion. Now I would like to do this, I have been reading and trying many things, such as using interfaces and wildcards but with no success. I would like to learn if there is a valid way to achieve this with Java generics, or if I have misunderstood they way in which generics should be used. Lets say I want to make a generic collection class, an ArrayList, and I want to create such arraylists for various differing types BUT IMPORTANTLY differing types which are ASSURED to implement a certain method. I would then like to be able to call that method from within my generic arraylist. The following code is very simplistic, and clearly will not work, I know that. I have tried plenty more sophisticated ideas than this, however I include the following code just to sum up what I am trying to do, and to provide an example for answers. See the line of code in DemonstrateProblem()...I would like to be able to

Can anyone provide sample in java which uses sociallib jar? [closed]

Social Lib is an Android library for developers. It provides a framework to read and share contents with social networks. Features Social Lib aims to make the development of Social apps much more easier. Currently, Social Lib provides access to the following social networks : Facebook Twitter Google Buzz LinkedIn Social Lib provides methods to read and write data from these social networks. You can have access to a Facebook wall, or send a tweet very easily, whith a very few line of code. To get started, read this tutorial, or browse the reference. If any one of you have experience than please help me.

Java Jframe centers my buttons ):<

Here is my code: public class Main { public static void main(String[] args){ JFrame frame = new JFrame("Vex Development Studio 2.0"); frame.pack(); frame.setVisible(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocation(10,10); //make variables File newproject; Container content = frame.getContentPane(); GridBagConstraints gbc = new GridBagConstraints (); Dimension buttonsize = new Dimension(75,25); Button about; about = new Button("About"); about.setPreferredSize(buttonsize); //add content content.setLayout(new GridBagLayout()); content.setBackground(Color.white); gbc.gridx = 0; gbc.gridy = 0; content.add(about,gbc); //main stuff //about button about.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ae){ JOptionPane.showMessageDialog(null, "Example", "About", 1); } }); //some extra crap frame.setSize(700, 500

iPhone opengl es: Touch detection

I have been messing around with opengl es on the iphone and right now I have some cubes on the screen. Currently I am trying to detect touches on these cubes. After a lot of searching on google this is what I have so far Use gluUnProject to find the x,y cordinates on the near plane in the world cordinate system Use gluUnProject to find the x,y cordinates on the far plane in the world cordinate system Subtract the vector obtained in 2 from the vector obtained in 1 to obtain the direction vector Normalize the direction vector to obtain the unit vector Iterate through all the trianlges and use the ray-triangle intersection to check if the ray intersects this triangle I think my mistake is in step 5. I have a feeling I am supposed to transform my triangles by the modelview matrix? Is my assumption correct? If yes any clues how to transform a triangle (an array of 3 floats) by the modelview matrix (an array of 16 floats)

Woodwing: how to trigger the ModalViewController using custom web/html embedded content

Using Woodwing, we have a page that has custom html in it, using the custom web widget. That widget has an anchor tag, that when tapped, opens a page in safari. However, if we create the same page using the HTML widget, and a link overlay, that triggers a ModalView to display. I'm assuming this has something to do with WoodWing's (un)documented protocols for the anchor tags, that are captured by the WoodWing shell application and used to trigger the "ModalView" display. Since everything in Woodwing generates an XML that is parsed when the app is loaded, and I've done numerous applications, this seems reasonable. However, there is very little technical documentation. My question is: does anyone know any documentation on those protocols, or a way I can use custom-html to trigger the ModalView? I've tried replacing "http" with "ww" but no dice. It's possible it's javascript but I'm suspecting protocols...

How to read jrxml file inside the jar file?

I have a bunch of iReport source code (jrxml) locate inside the workspace with the following path: <project>/report/<jrxml_file> When I pack my source code into jar file. I will have this file structure directory: <jar_file>/report/<jrxml_file> In my source code, I have these code to validate the existence of the jrxml file: File file = new File("report/jrxml_file"); if (!file.exists()) { return false; } When I execute this jar file through the command: java -jar MyJar.jar I hit an error mention that the particular jrxml_file doesn't exists. My doubt: I am just curious to know whether am I allow to read the jrxml_file which is locate inside MyJar.jar? Do I need to extract the jrxml_file to a physical directory before I can read it? THanks @!

Spliting the String[] of array

how do i split the code into three items reading the data and dumping into String of Array : String[] songs_array = directory_listings.split(":::"); here is the restultset looks like: :::Chapter 01>>>Name of the Book>>>Spanish name::: and once its in songs_array variable i would like to do similar to like this: but the above code just return me a string :::Chapter 01>>>Name of the Book>>>Spanish name::: m_orders = new ArrayList<Order>(); Order obj = new Order(); obj.ChapterNumber(songs_array[0]); obj.EnglishName(songs_array[0][1]); obj.SpanishName(songs_array[0][1][2]); m_orders.add(obj); any help?

How do I create ComboChart in google GWT(Java) with multiple Series and a secondary scale?

Adding Multiple series to the ComboChart with different graph types is straightforward, but I am not able get the targetAxisIndex set against a particular series. Any thoughts/Working examples for this? I looked at the google charting tools javascript examples, but not able to translate the same to Java.

is it a good practice to delete the AdBannerView on viewWillDisappear and add it back on viewWillAppear?

I am currently doing the following in my code avoid the issue of "obscured" ad. But is it a good practice? One potential problem is that - assume before the viewWillDisappear, there was an ad request send out, and then when the ad come back the adBannerView instance has gone. Would that be a big problem? Should I only do hideAdBanner instead? - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear: animated]; // create the ad banner view [self createAdBannerView]; if (adBannerView != nil) { UIInterfaceOrientation orientation = self.interfaceOrientation; [self changeBannerOrientation:orientation]; } } - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; // iAd if (adBannerView != nil) { [self hideAdBanner]; adBannerView.delegate = nil; [adBannerView release]; adBannerView = nil; } }

Very slow query where table have many records

I' m using sqlite on iphone. I have table with 200 000 records. It' s size is small, only 2 MB. I' m doing standard select(3 collumns) with two simple condtions. I' m operating only on integer values( in return and condtion). All data are unique. I'm get usually only 10-50 records from database. In spite of that my query take 3 sec. It' s a lot of time. How i can improve this ? Edit: I can't load my table with other thread. NSString * query = [ NSString stringWithFormat:@"SELECT rRozklad.hour, rRozklad.minute, rRozklad.marks FROM rRozklad.idOkres=%i AND rRozklad.idPolaczeniaLinie=2 ORDER by rRozklad.hour, rRozklad.minute", okres]; NSLog(@"%@", query); const char * querystring = [ query UTF8String ]; sqlite3_stmt * statment; if(sqlite3_prepare_v2(database, querystring, -1, &statment, nil) == SQLITE_OK){ while(sqlite3_step(statment) == SQLITE_ROW){ NSMutableArray * temp = [[NSMutableArray alloc] initWithCapacity:2];

Dynamically use UIViewContentModeScaleAspectFit and UIViewContentModeScaleAspectFill

I am trying to display images on the iPhone in the same way that the Photo app does. It seems to be able to dynamically select UIViewContentModeScaleAspectFit or UIViewContentModeScaleAspectFill depending on what is appropriate for the image. Where possible I would like images to appear full screen but if not then I would like them to appear UIViewContentModeScaleAspectFit

nsurlrequest settings for POST

I am setting up a request to my server, I have been helped out with a few suggestions but I am wanting some clarification on a part of code. in the second line of code, what are the setValue: and forHTTPHeaderField: values used for? I'm thinking forHTTPHeaderField: sets the mime type... but im not sure what setValue is for or how it effects my request. [request setHTTPMethod: @"POST"]; [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"content-type"]; [request setHTTPBody:postBodyData]; any help would be greatly appreciated.

Access mobile device camera from a grails application using jquery mobile

I have a grails application using jquery mobile. I am hoping to find some way to access the camera on the devices. I thought about using flash to grab the webcam but that obviously wont work on Apple devices. Does anyone know of a way to do it and keep it all browser based? I am hoping that there is a plugin somewhere or maybe html5 has some magic in there that supports it.

How to put a UITableView below a UILabel with code

I wrote a code with a UILabel with the name of a meteorological station. Later, I added the code to put a UITableView with a grid view like this website explains http://www.recursiveawesome.com/blog/2011/04/06/creating-a-grid-view-in-ios/ The problem is that now the Table view is shown in all screen and the label can't be seen. How do I make to put the elements in this order? UILabel UITableView Thanks!

Catch push notification"s message if the user tapes "close&rdquo; in the alert

I'm developing an app, I'm using push notifications, I'm sending pushes from an asp.net application and everything is ok, but there is a problem when I want to catch the notification message in the xcode. I know to catch that information I have to use this method - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo But it works just when the user tapes "view" in the alert or when the app is in foreground. I need to save the message in to my core data DB everytime, but I can't do that if the user tapes "close" in the alert. Are there any way to get a solution for my problem? Thanks.

Error Domain=NSPOSIXErrorDomain Code=61 "The operation couldn\u2019t be completed. Connection refused&rdquo;

I am using asyncSocket as client side, aim running my application on I-Phone simulator, and the server side coded with C#. its working perfectly if i try to connect with a server on my LAN but the connection refused with the server out of my LAN. I'am sure that the same server is working with another client code done on C#. And this the message i get from socket Error: Error Domain=NSPOSIXErrorDomain Code=61 "The operation couldn\u2019t be completed. Connection refused" Knowing that i get this message on connect phase before try to send data to server. Any helping idea is appreciated.

creating an http body with construction method

I am trying to create a http body that I am going to pass in using NSURLRequest post. I have my connection class all set up. The thing is i have several methods that return NSStrings and UInt32's and one construction method that I want to use to put all of these methods into one http body which will be of data type format. However I'm not sure how to call these methods that return the correct data from my construction method to gather the data into one data object. here is some code that I have (shortened so its a little clearer) these methods are used to return the data needed - (UInt32) addDataVer { UInt32 dataVer = 0; return dataVer; } - (NSString *) addReg { NSString *reg = [[NSString alloc] initWithString:@"abcd1"]; return reg; } - (NSString *) addActiv { NSString *activ = [[NSString alloc] initWithString:@"abcd2"]; return activ; } from here I'm not sure what to do, or how to get the data. I have created a constru

iOS Creating a list of tags

I'm currently trying to implement a feature in my app that shows tags for a post. I want it to work very similar to that of tags here on StackOverflow, in that they have a colored background. Another example, are the Inline Labels here . I'm just not quite sure on how to get it implemented. My first guess would to create an array of UILabels... Any suggestions?

how to pass NSUserDefaults integer to a UInt32 object

I am wondering if it is possible to pass an integer value I am creating in my NSUserDefaults into a UInt32 object? So far I am creating the NSUserDefaults as below. NSString * yourKey = @"RequestNumber"; NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults]; [defaults setInteger:[defaults integerForKey:yourKey] + 1 forKey:yourKey]; and then I am trying to pass the user defaults value into my object as below.. However I am fairly positive I am completely wrong... which is why im here :) any help would be appreciated. UInt32 *requestNumber = [[NSUserDefaults standardUserDefaults] integerForKey:yourKey];

Unrecognized selector sent to instance?

I have seen that a few others have had this problem as well. I'm trying to follow a tutorial online that shows how to create animated pins on a MapView. I have implemented the code as shown in the tutorial and the project builds fine except I receive this exception: -[MKPointAnnotation iconN]: unrecognized selector sent to instance I have a subclass of 'MKPinAnnotationView' and in the .m file I create this method: - (void)setAnnotation:(id<MKAnnotation>)annotation { [super setAnnotation:annotation]; //Place *place = [[Place alloc] init]; Place *place = (Place *)annotation; //The following line is where the program sends "SIGABRT" icon = [UIImage imageNamed:[NSString stringWithFormat:@"pin_%d.png", [place.iconN intValue]]]; [iconView setImage:icon]; } Here are a few parts from my "model" which is called Place.h/.m. Here is where I create the property for 'iconN'. @property (retain, nonatomic) NSNumbe

CoreData relationships are nil after mergeChangesFromContextDidSaveNotification

Having some truly strange behavior with Core Data on iOS. I have a NSManagedObjectContext for my main thread used to read data from a SQLLite persistent store and display it to the user. I also have background processes managed by an NSOperationQueue. These background processes create an NSMangedObjectContext, fetch data from remote servers, and persist that data to the local Core Data store. I have registered for NSManagedObjectContextDidSaveNotification and when I receive those notifications call mergeChangesFromContextDidSaveNotification on the main threads NSManagedObjectContext (passing the notification object as an argument). This is all very standard and the way that all the Core Data document suggest that you deal with multi-threading. Up until recently, I have always been inserting new objects into the data store and not modifying objects in the data store. This worked fine. After a background thread writes new data, the merge occurs, I send a notification to the UIControl

PHP - Saving Uploaded Image to Server

I am trying to save an uploaded image from an iPhone to a server using PHP. I am using ASIHTTPRequest to handle the data request. This is my iPhone code: [request setPostValue:someString forKey:@"string1"]; [request setPostValue:anotherString forKey:@"string2"]; [request addData:[NSData dataWithData:UIImageJPEGRepresentation(anImage, 0.9)] withFileName:@"img.jpg" andContentType:@"image/jpeg" forKey:@"img"]; [request startSynchronous]; On the server side, I am using this PHP code currently to try saving the image to a folder on my server: print_r($_FILES); $folder = 'upload/'; $image_path = basename($_FILES['img']['name']); echo $folder . $image_path . "\n"; if (move_uploaded_file($_FILES['img']['tmp_name'], $folder . $image_path)) { echo 'ok!'; } else { echo 'fail !'; } The strings are uploaded just fine and when I print_r() i see the contents of t

Iphone runs ONLY from cache even when online

I am having a bit of trouble. I am making a mobile version of our website, and want to cache some of the more important pages, not just for use offline, but for added speed in some cases. First question: Do I have to manually cache the pages to speed up performance? I am using AJAX calls to bring in content, and it obviously doesn't work offline without manually caching, but while online is Safari going to request a page via ajax if it's already in the cache? I currently have it working correctly. My pages cache and work both online and offline. But if I don't specify all pages I want cached, it appears with every ajax call, those pages are requested again, not loaded from cache. Second Question (My actual problem): When online or offline, and using a .manifest file to manually cache files, it appears that the iPhone sets itself in a "offline" mode, even when online. So when I run my ajax call, if the page is not cached, I get an error. $.ajax({ url: p

Iphone Build Release with encryption

Hello i just want to ask if i build my iphone app for release is it encrypted or not? When the encryption happens? How can i understand if a build is encrypted or not? product -> build for -> archiving product -> build for -> profiling product -> build for -> running product -> build for -> testing are the available...

Intermittent EXC_BAD_ACCESS exception with CATitledLayer

I am having some problems with an app that keeps crashing intermittently. Code below is in a UIView with CATiledLayer as its backing layer: - (UIBezierPath *)path { if(_path == nil){ _path = [UIBezierPath bezierPath]; CGFloat lineWidth = 5; [_path setLineWidth:lineWidth]; [_path setLineJoinStyle:kCGLineJoinRound]; [_path setLineCapStyle:kCGLineCapRound]; [_path moveToPoint:CGPointMake(100, 100)]; [_path addLineToPoint:CGPointMake(200,200)]; [_path addLineToPoint:CGPointMake(150,200)]; [_path addLineToPoint:CGPointMake(50,400)]; _path closePath]; return _path; } return _path; } - (void)drawRect:(CGRect)rect { [[UIColor colorWithRed:0.1 green:0.1 blue:1 alpha:0.45] setStroke];//sets stroke color in current context [self.path stroke]; } I get the following error code: Single stepping until exit from function _ZN2CG4Path15apply_transformERK17CGAffineTransform, which ha

Why does my AlertView takes 3 clicks on cancel button to close?

NOTE: I still don't have an answer to this: I implemented a UIAlertView that displays a tableView to make a selection and return to the underlying view controller. The alert view pops up fine, displays all the data and when I click the cancel button it does not respond, then I click it again and it moves position by quarter of an inch, then when I click it for the third time, the alertView finally disappears. What would cause this type of behavior? This is the code: -(void)handleLongPress:(UILongPressGestureRecognizer *)gestureRecognizer { CGPoint p = [gestureRecognizer locationInView:self.tableView]; NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:p]; if (indexPath == nil){ NSLog(@"long press on table view but not on a row"); } else { NSLog(@"long press on table view at row %d", indexPath.row); selectedQuote = [self.quotes objectAtIndex:indexPath.row]; NSLog(@" subject title = %@", selectedQuote.title)

iOS NSJSON Returning Null

I have the following code hostStr = [hostStr stringByAppendingString:post]; NSData *dataURL = [NSData dataWithContentsOfURL: [ NSURL URLWithString: hostStr ]]; NSString *serverOutput = [[NSString alloc] initWithData:dataURL encoding: NSASCIIStringEncoding]; NSError *error = nil; NSDictionary *result = [NSJSONSerialization JSONObjectWithData:dataURL options:kNilOptions error:&error]; NSArray *files = [result objectForKey:@"GV_Return"]; NSLog(@"Files: %@", files); // For Each Key we seperate the data and add it to an object to be used. for (NSDictionary *file in files) { NSString *userNumber = [result objectForKey:@"UserNumber"]; NSLog(@"output: %@", userNumber); } The problem I'm having is that NSLog(@"Files: %@", files); returns what I expect Files: ( { UserNumber = 1; } ) However NSLog(@"output: %@", userNumber); R

iPhone ResetCounter Crash

I have write a native c executable program and run it on iPhone4. First, it works well, but after a period of time, it will cause iphone reboot every time when I run it. There is a Crash Report in /var/logs/CrashReporter, name is ResetCounter-2012-02-23-203134.plist. Can any body tell me what is happend? Thank you. <?xml version="2.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>AutoSubmitted</key> <true/> <key>SysInfoCrashReporterKey</key> <string>18a43ae69755297d4e14405a1f7b7a8119557668</string> <key>bug_type</key> <string>115</string> <key>description</key> <string>Incident Identifier: B7F9154E-C607-4706-AF42-0FF04594114B CrashReporter Key: 18a43ae69755297d4e14405a1f7b7a8119557668 Da

Core Data - add relationship information to existing object

i set up a core data model with a "user" entity with several attributes. There's a second entity called "information". A "user" can have multiple "information" objects... A "information" allways have one "user" with these objects i initialize a tableview. the number of sections is the number of "users" the number of rows is the number of "informations" associating to a user everything fine until now. with the "user" attribute values i start several API Rest Requests (i do this in viewForHeaderInSection for every single user...). now, when im getting a successful response from the API provider with the needed results i stuck associating the result with the matching "user" entity. i created a fetchresult with predicate to get the right user - but when creating a new "information" entity and then associating the "relation property" to the fetchresult

how to encode a UInt32 scalar type into a NSData object

I am currently creating this NSData object. I would like to put in sever different objects that are of type NSString and UInt32. I know how to put a NSString into my NSData object, but I don't know how to do this with a UInt32 scalar type. this is how I do it with a NSString - (void) constructRequest { NSString *mystring = [[NSString alloc] initWithString:[self addMethodName]]; UInt32 protocolInt = [self addProtocolVersion]; NSData* data=[mystring dataUsingEncoding:NSUTF8StringEncoding]; [data writeToFile:@"/Users/imac/Desktop/_dataDump.dat" atomically:YES]; }