English 中文(简体)
正在获取 EXC_BAD_ conference 上 NSS 键上的 EXC_BAD_ conference 。 日志显示无效的 CFSTringRef
原标题:getting EXC_BAD_ACCESS on NSString. Log says Invalid CFStringRef

I am trying to access data from a server that i set up. While 4 files are worked perfectly, i am getting an Thread2: Program recieved signal: "EXC_BAD_ACCESS".

-(void)loadContentInBackground
{

        NSError *error;

        NSString *posterURL = [[NSString alloc] initWithFormat:@"%@PartyCentral/WeeklyParties/Club%@/poster.jpg",baseURL,clubNum];

        poster.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:posterURL]]];

        posterEnlarged.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:posterURL]]];

        NSString *vp1URL = [[NSString alloc] initWithFormat:@"%@PartyCentral/WeeklyParties/Club%@/VenuePic/pic1.jpg",baseURL,clubNum];
        venuePic1.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:vp1URL]]];

        NSString *vp2URL = [[NSString alloc] initWithFormat:@"%@PartyCentral/WeeklyParties/Club%@/VenuePic/pic2.jpg",baseURL,clubNum];
        venuePic2.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:vp2URL]]];

        NSString *vp3URL = [[NSString alloc] initWithFormat:@"%@PartyCentral/WeeklyParties/Club%@/VenuePic/pic3.jpg",baseURL,clubNum];
        venuePic3.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:vp3URL]]];


        NSString *nameURL = [[NSString alloc] initWithFormat:@"%@PartyCentral/WeeklyParties/Club%@/name.txt",baseURL,clubNum];
        NSString *nameData = [NSString stringWithContentsOfURL:[NSURL URLWithString:nameURL] encoding:NSASCIIStringEncoding error:&error];
        name.text = nameData;

        // Date Being downloaded.
        NSString *dateURL = [[NSString alloc] initWithFormat:@"%@PartyCentral/WeeklyParties/Club%@/date.txt",baseURL,clubNum];
        NSString *dateData = [NSString stringWithContentsOfURL:[NSURL URLWithString:dateURL] encoding:NSASCIIStringEncoding error:&error];
        date.text = dateData;

        // Day Being downloaded. THIS IS WHERE THE ERROR COMES IN HIGHLIGHTING THE
       //initWithFormat line


        NSString *dayURL = [[NSString alloc] initWithFormat:@"%@PartyCentral/WeeklyParties/Club%@/day.txt",baseURL,clubNum];
        NSString *dayData = [NSString stringWithContentsOfURL:[NSURL URLWithString:dayURL] encoding:NSASCIIStringEncoding error:&error];
        day.text = dayData;

        // Latitude & Longitude Being downloaded. 
        NSString *latitudeURL = [[NSString alloc] initWithFormat:@"%@PartyCentral/WeeklyParties/Club%@/Location/latitude.txt"];
        NSString *latitudeData = [NSString stringWithContentsOfURL:[NSURL URLWithString:latitudeURL] encoding:NSASCIIStringEncoding error:&error];

        NSString *longitudeURL = [[NSString alloc] initWithFormat:@"%dPartyCentral/WeeklyParties/Club%@/Location/longitude.txt",baseURL,clubNum];
        NSString *longitudeData = [NSString stringWithContentsOfURL:[NSURL URLWithString:longitudeURL] encoding:NSASCIIStringEncoding error:&error];

        CLLocationCoordinate2D location;
        location.latitude = [latitudeData doubleValue];
        location.longitude = [longitudeData doubleValue];

        MapAnnotation *newAnnotation = [[MapAnnotation alloc] initWithTitle:[name text] andCoordinate:location];
        [self.mapView addAnnotation:newAnnotation];
        [newAnnotation release];

    }

在 DayURL I get, 无效 CFSTringRef 的日志中。

请救救我...!

最佳回答

此行 :

NSString *latitudeURL = [[NSString alloc] initWithFormat:@"%@PartyCentral/WeeklyParties/Club%@/Location/latitude.txt"];

包含一个格式字符串,没有提供参数, 其效果是将堆栈上的任何值脱钩。 如果这些 < em> 指针 无法有效内存, 则会发生这类错误 。

问题回答

暂无回答




相关问题
How to change out-of-focus text selection color in Xcode?

Okay, I ll bite. I ve got really pleasant code/window colors set up in Xcode. Ordinarily, my selection color is very visible. When I am doing a project search and iterating through the results, ...

Iphone NSTimer Issue

Hi I am new to objective c. I am trying to make an app for iphone. I have a button on my view, and the click on which the function playSound is called. This is working properly. It does plays the ...

Include a .txt file in a .h in C++?

I have a number of places where I need to re-use some template code. Many classes need these items In a .h could I do something like: #include <xxx.txt> and place all of this code in the ....

Iterating over string/strlen with umlauted characters

This is a follow-up to my previous question . I succeeded in implementing the algorithm for checking umlauted characters. The next problem comes from iterating over all characters in a string. I do ...

Xcode open two editor windows with same file

Is it possible to open the same file in two separate windows in Xcode. I can open a file in one window and the same file in the main Xcode editor window, but I wanted two separate fulltime editor ...

Forcing code signing refresh in Xcode

In our environment, we share resources across multiple projects and platforms. When building for iPhone, only a subset of those resources are needed. Since that subset is still considerable, we have ...

热门标签