views:

164

answers:

3

Hi,

im want use this Class http://stackoverflow.com/questions/125306/how-can-i-upload-a-photo-to-a-server-with-the-iphone to Upload an image from my iPhone App to my Webserver.

Ive Copyd the header and main file and added "#import "EPUploader.m"" to my ViewControler where i call the EPUploader Method.

Error Message is:

Ld build/Release-iphonesimulator/PhotoApp.app/PhotoApp normal i386
cd /Users/phil/PhotoApp
setenv MACOSX_DEPLOYMENT_TARGET 10.5
setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk -L/Users/phil/PhotoApp/build/Release-iphonesimulator -F/Users/phil/PhotoApp/build/Release-iphonesimulator -filelist /Users/phil/PhotoApp/build/NaoUp.build/Release-iphonesimulator/PhotoApp.build/Objects-normal/i386/PhotoApp.LinkFileList -mmacosx-version-min=10.5 -framework Foundation -framework UIKit -framework CoreGraphics -o /Users/phil/PhotoApp/build/Release-iphonesimulator/PhotoApp.app/PhotoApp

Undefined symbols:
  "_compress", referenced from:
      -[EPUploader(Private) compress:] in EPUploader.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

Sorry if its a noobie question.. im new to this :)

+1  A: 

The question you link to shows this comment for the compress: method (edited for brevity):

* -[Uploader(Private) compress:] --
*      Uses zlib to compress the given data.

And inside the method, the call to compress():

int error = compress([destData mutableBytes],
                     &destSize,
                     [data bytes],
                     [data length]);

It looks to me like you're not linking zlib with your application, so the linker can't figure out how to call compress(). The zlib homepage has everything you need to integrate the library with your app.

Also - it's a little weird to do #import "EPUploader.m". Normally you would only #import a header file.

Carl Norum
A: 

Ok thanks, i didnt find any help how to add the .dll to my Project so i googeld and found how i can add libz in the target info. Ive added it and now it Builds. But when im trying to run the method it Crashes with "terminating due to uncaught exception"

Debug Console says:

2010-02-14 11:39:20.090 PhotoApp[17410:207] *** Assertion failure in -[EPUploader upload], /Users/phil/PhotoApp/Classes/EPUploader.m:154
2010-02-14 11:39:20.092 PhotoApp[17410:207] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: ''
2010-02-14 11:39:20.092 PhotoApp[17410:207] Stack: (
    807902715,
    2537911561,
    807986683,
    811271572,
    10062,
    11260,
    8876,
    814709201,
    815110321,
    815119058,
    815114270,
    814813151,
    814722763,
    814748641,
    839148405,
    807687520,
    807683624,
    839142449,
    839142646,
    814752238
)
(gdb) 

And this line is:

- (void)upload
{
    NSData *data = [NSData dataWithContentsOfFile:filePath];
    ASSERT(data); //Line 154
    if (!data) {
        [self uploadSucceeded:NO];
        return;
    }
    if ([data length] == 0) {
        // There's no data, treat this the same as no file.
        [self uploadSucceeded:YES];
        return;
    }
philipp
@philipp, you should edit your question rather than posting an answer if you're looking for more help.
Carl Norum