Looking to convert base64 to a blob in Objective-C

I'm looking to convert base64 to blob in objective-c.

I'm having trouble finding a solution on stack overflow.

function base64_to_blob(base64String) {
   var byteString = window.atob(base64String);
   var array = new Uint8Array(byteString.length);
   for (var i = 0; I < byteString.length; I++) {
      array[i] = byteString.charCodeAt(i);
   }
   var blob = new Blob([array], {
      type: ‘image / jpeg’,
      name: “image.jpg”
   });
   return blob;
}

If anyone can help me with this, I would greatly appreciate it.

Answer №1

If you're looking to convert base64 to a blob in your code, this snippet might come in handy.

-(NSData *) base64_to_blob(base64String) {
    NSData * blobData = [[NSData alloc] initWithBase64EncodedString: base64String options:1];
    return blobData;    
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What are some ways to customize the appearance of the Material UI table header?

How can I customize the appearance of Material's UI table header? Perhaps by adding classes using useStyle. <TableHead > <TableRow > <TableCell hover>Dessert (100g serving)</TableCell> ...

Dealing with multi-line strings in Javascript

I am having an issue with my code: let testStr = "Asdfads"; let htmlStr = `<script>${ testStr }</script>`; // but it works with: <div>${ testStr }</div> console.log(htmlStr); When I run this code, I receive the following error: ...

How can I retrieve an array from an object containing both a property and an array in TypeScript?

One of my objects always consists of a property and an array. When I use the console.log(obj) method to print it out, it looks like the following example: ProjectName: MyTest1 [0] { foo: 1, bar: 2} [1] { foo: 3, bar: 4} [2] { foo: 5, bar: 6} Alternat ...

What steps can I take to address this issue with my express node and ejs?

Hey there, I'm new to node.js and I've been encountering this error message. Can someone please provide some insight? Error: Could not find matching close tag for "<%=". at /Users//Desktop/Web Development/getting_started_express js/node_m ...

Exploring AngularJS: Retrieving a list of filenames from a specified directory

In the public directory of my application, there is a folder named 'x'. I have the path name to the folder (/path/to/dir/x) but I am unsure of the names of the files within it. How can I retrieve the file names and provide URL links to them in an ...

Sending a null value through AJAX to a controller

I've been working on adjusting my save routine to pass a null value to id_cellcarrier in my codeigniter controller. The code snippet below showcases what I've attempted so far, but it doesn't seem to be functioning correctly. I'm omitti ...

When transitioning to a different page, Angular is creating a duplicate of $scope

My webpage features a section where I showcase all the individuals stored in the database, referred to as the All Persons Page. Within this page, there are two primary options: Add New Person Delete Person (Any selected individual) An issue arises when ...

Removing the Picker Border on IOS Devices: A Step-by-Step Guide

I'm currently facing an issue where I am trying to incorporate a picker with a background image. To achieve this, I utilized a relative layout and included both the image and picker within it. However, my struggle arises from having a border in the IO ...

Utilizing Ajax to dynamically update the content of a div element

As a newcomer to Ajax, I am trying to use xmlhttprequest to dynamically change the content of a div by fetching HTML from different URLs. However, my code doesn't seem to be working as expected. Can someone help me identify what I might be doing wrong ...

Difficulty in accurately retrieving the value in a PHP echo statement using jQuery

$id = "123"; When on the page book.php, $id is passed to an external jquery-book.php file. <script type="text/javascript"> var id = '<?php echo $id; ?>'; </script> <script type="text/javascript" src="jquery-book.php"& ...

I am encountering difficulties with hosting a project that was created using Next.js

I am currently working on a Next.js project and I encountered some version compatibility issues when integrating MUI. While my project runs smoothly in localhost, it fails to work when deployed in hosting. I attempted to resolve this by using the --legacy ...

What is the method for configuring a timezone in Selenium Chromedriver?

I'm struggling to set a specific timezone while using Chromedriver. Is there an argument in ChromeOptions that can help with this? The problem arises when I visit certain websites (such as ), where it displays the system time based on Windows setting ...

refetchQueries may be effective for specific queries

Using a Friend component within my AllFriends screen triggers the following mutation: const [deleteUserRelation] = useDeleteUserRelationMutation({ onCompleted: () => { Alert.alert('Unfriended'); }, refetchQueries: [{ query: ...

Json object not recognized

I am in the process of developing a basic application where the user can interact with a button to retrieve a JSON object from the database. The object's structure is displayed below. However, the system is failing to recognize the object, resulting i ...

Utilizing Vue.js to track and navigate through browsing history using the browser's

I'm currently working on an application using Vue and Laravel. Instead of relying on vue-router, Laravel is managing my routes. Within my parent component, I am dynamically loading components based on the state of an object in the data. One of the m ...

Looking for a replacement in my code as 'substring(to:)' in Swift 4 has been marked as deprecated

Below is the code I wrote: var reviewText = addReview.text let length = addReview.text.utf16.count if length > 3000 { reviewText = reviewText?.suffix(3000) } The goal was to extract the first 3000 characters of the text in ca ...

Switch out the ajax data in the input field

Is there a way to update the value in a text box using Ajax? Below is my code snippet: <input type="text" id="category_name" name="category_name" value="<?php if(isset($compName)) { echo ucfirst($compName); ...

What kinds of data types does MongoDB support in JavaScript?

Regarding the mongodb node client, it allows insertion of JavaScript data using the following syntax: collection.insert({ alpha: 123, bravo: "hello", charlie: [1, 2, 3], }) I am curious to know if mongo supports newer JavaScript data types ...

An easy CSS conundrum when hovering

Looking for some assistance with CSS. I want to display the text "Featured Page" with a picture appearing on the right side upon hovering (mouseover). Currently, the picture shows up under the text using the following CSS, but I need it to be larger and pl ...

Customizing Your JQuery.awesomeCloud.plugin with a Tooltip Functionality using jQuery

Is it possible to integrate a jQuery Tooltip feature when hovering over specific words in a word cloud? I am currently using [jQuery.awesomeCloud.plugin]:https://github.com/indyarmy/jQuery.awesomeCloud.plugin If there is an alternative method to add toolt ...